You would want to create an Appender that publishes to registered listeners. 
Log4j currently doesn’t have one but it would be pretty simple to create one.

Ralph

> On Feb 2, 2018, at 6:09 AM, Tushar Kapila <tgkp...@gmail.com> wrote:
> 
> Am sure this has been asked before but i could not find code that works
> 
> Looking for an example of code where there is no UI. Batch mode, give a
> file path, a config file (log4j2),
> get call backs of log events read to a listener method. Possible in
> chainsaw or other FOSS?
> 
> Psudedo code:
> 
> Set it up:
> File myLogFile = new File("path/a.log")
> File myConfigFile = new File("path/log4j.xml")
> myListener listr = new MyLsitenter();
> 
> theLibrary.process(listr, myConfigFile, myLogFile);
> 
> In the listener
> 
> public void onEvnt(LogRecord logRecord){
>    logRecord.getDate();
>    logRecord.getThread()
>    logRecord.getLevel();
>    logRecord.getMessage() ; //could be multiline too,etc
> 
> -- 
> Regards
> Tushar Kapila



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org

Reply via email to