Manual Tests logs are not written to file
For an example, take TestWrappers :
Despite setting the global variable at the beginning of the test
//Set the logging directory
Global.sessionLogFolders = Utils.generateLogPath(TestWrappers.class.getSimpleName());
which generates the ouput
09:35:51.347 c.n.n.u.Utils 275 INFO - Logging folder : tests_TestWrappers_1427186151346/
I can't find the output of the test.
Would it be possible to save log files to the directory declared in Global.sessionLogFolders ?
Comments (8)
-
-
- marked as enhancement
-
- changed status to resolved
see TestWrappers in static block. Test_logback.xml defines "<property scope="context" name="logfolder" value="testlogs" />"
this file is defined in Settings
-
reporter - changed status to open
-
reporter - The folder should be under logs/
- The name of the folder should contain the name of the test
- At the end of the test I want to be able to print the path to the log file where the current session wrote into
- Do we need to create a different xml file for each manual test?
- I do not thing the xml belongs in /allconfig , I think it is a resource
- in Settings.java a comment explaining the variable is missing
If you want to postpone the changes above to a future iteration, then - restore the old logger that was giving us control over the filename without creating a new xml file - open a new ticket with details in a future version
-
I've implemented this using one of logback features called SiftingAppender. There is an example in TestLogging. Based on the configured testID a different file will be used. So there is only one xml file, which defines a pattern to be used.
MDC.put("testID", "TestExample"); LOG.info("<<<<<<<<<<<<<<<<"); // this will use TestExample.log MDC.put("testID", "TestABCXYZ"); // this will use TestABCXYZ.log LOG.info("*****************");
needed definition at the thop
static { System.setProperty("logback.configurationFile", Settings.TEST_LOGXML); }
-
reporter - changed status to resolved
(resolved
#380)→ <<cset 38369f9942dd>>
-
reporter Elegant solution and nice example in the Test.
I updated the example in TestLogging and all the manual tests now log to the folder logs/tests/ . Each file its composed by the name of the class and the timestamp of execution ( See InitTests.setLoggingFilename(Logger log) )
- Log in to comment
with sth like this yes, but I'd prefer to leave this open for now: http://stackoverflow.com/questions/16910955/programmatically-configure-logback-appender
with logback the usual pattern is that a general filter (the xml file) directs various loggers, defined in the classes. The classes should just have names, not paths.