java - Sending particular INFO log line to a different file -
i have particular log line information, needs logged in different file future use. have configured log4j.properties in system log necessary information.
eg:-
[2017-07-28 20:33:07,798] info - 'john@doe.com' logged in @ [2017-07-28 20:33:07,798+0530]
i have filter out , append org.apache.log4j.dailyrollingfileappender
appreciate help.
below solution xml configuration. can find the details here. example can specify 2 appenders: 1 storing lines , 1 storing special lines. then, appender storing special lines set filter in following way (example rollingfileappender):
<rollingfile name="rollingfile" filename="logs/app.log" filepattern="logs/app-%d{mm-dd-yyyy}.log.gz"> <regexfilter regex=".*logged in at.*" onmatch="accept" onmismatch="deny"/> <patternlayout> <pattern>%d %p %c{1.} [%t] %m%n</pattern> </patternlayout> <timebasedtriggeringpolicy /> </rollingfile> also check question can find clue on how configure same using properties.
Comments
Post a Comment