java - log4j2 configuration XML file for 2 log files with new folder each run -
I'm a bit new in log4j2. I see how we configured the log4j2.xml file for our test automation framework. You can. What we want is that two log files are a non-technical and one with all technical details, such as stack trace information. This means direct information and error messages in a file. All messages will direct another file. Therefore, a file will contain everything that does the other and more.
The second thing we want, every time we run the test, it will create a new set of logs inside a folder with a time stamp. For example
For example
> Directory structure
- Application name
- 2015- 12-02 16:52:30
- logTechnical.log (all logs)
- logSimple.log (notification and error)
- logSechnical.log (all logs) Second thing if possible in Log4j I think a batch file or custom code may be required. But if we can keep only 5 new logs, then the server does not get dirty. We do not want to use a rolling log file for this. Thanks for the help.
creates the following directory directories and files, but does not remove the old directories:
< Pre class = "lang-xml prettyprint-override"> & lt ;? XML version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Configuration & gt; & Lt; Appenders & gt; & Lt; File name = "simple" filename = "app / $ {date: yyyy-MM-dd HHmmss} /logSimple.log" & gt; & Lt; PatternLayout Pattern = "% d% p% c {1}} [% t]% M% n" / & gt; & Lt; Filter & gt; & Lt; Threshold filters level = "fatal" on match = "denny" on ammitch = "neutral" /> & Lt; Threshold Filters Level = "Error" Match = "Accept" on Ammich = "Nitrol" /> & Lt; Threshold Filters Level = "Warning" on Match = "Denny" on Ammich = "Neutral" /> & Lt; Thresholdfilter level = "info" onMatch = "ACCEPT" onMismatch = "DENY" /> & Lt; / Filters & gt; & Lt; / File & gt; & Lt; File name = "technical" filename = "app / $ {date: yyyy-MM-dd HHmmss} /logTechnical.log" & gt; & Lt; PatternLayout Pattern = "% d% p% c {1}} [% t]% M% n" / & gt; & Lt; / File & gt; & Lt; / Appenders & gt; & Lt; Collections & gt; & Lt; Root level = "all" & gt; & Lt; AppenderRef Ref = "Simple" /> & Lt; Appendix Riff Ref = "Technical" /> & Lt; / Root & gt; & Lt; / Collections & gt; & Lt; / Configuration & gt;
Comments
Post a Comment