Skip to content

johnsimpl/log4jhttpPost

 
 

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

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 92.3%
  • Roff 5.7%
  • HTML 0.9%
  • C++ 0.5%
  • Batchfile 0.3%
  • CSS 0.2%
  • Other 0.1%