log4jhttpPost

Additional

Language
Java
Version
v1.3alpha8 (Feb 2, 2006)
Created
Jul 14, 2016
Updated
Feb 19, 2018
Owner
Avraam Piperidis (avraampiperidis)
Contributor
Avraam Piperidis (avraampiperidis)
1
Activity
Badge
Generate
Download
Source code

Advertisement

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");
  
  }

}