logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: log event pojo from log file/ parse file back to log event
Date Fri, 02 Feb 2018 21:58:59 GMT
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 <tgkprog@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-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message