Skip to content
 
 

Repository files navigation

log4jhttpPost

All the functionality of log4j is the same.
The extended functionality is the ability to send HTTP GET requests the logs you want to a server.
The HTTP GET requests contains two parameters:
1)message 2)error
eg. http://www.yourserver.com/saveinfo.php?message=themessage&error=theerror
message parameter contains log's info,message,level
error parameter contains Throwable's(and any subclass)info

The jar https://github.com/avraampiperidis/log4jhttpPost/blob/master/log4jhttppost.jar?raw=true

#Basic Usage if there is not connection or invalid host the log will be lost.

public class Test {
  
  static Logger logger = Logger.getLogger("Test");
  
  static {
      PropertyConfigurator.configure("resources/log4j.properties");
  }
  
  static url = "http://localhost/collectClientsError";
  
  public static void main(String[] args) {
    
    //everything with doPost() will be send
    logger.info("main_started").doPost(url);
    
    logger.log(Level.INFO,"level").doPost(url);
    
    int a[] = new int[4];
    
    try {
      a[12] = 1;
    }catch(IndexOutOfBoundsException ex) {
       logger.error("IndexOutOfBoundsException error",ex).doPost(url);
    }
    
    
    //this will not be send
    logger.info("main_end");
  
  }

}

About

log4j with the ability to send the logs to HTTP GET request's

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages