Hello Ralph, I like the idea of using the RollingFileManager to directly force a Rollover.
I am creating my logger and the RollingFileAppender according to your instructions as shown here: http://stackoverflow.com/questions/34904304/how-to-properly-create-a-rollingfileappender-with-appendercomponentbuilder-in-lo It is not clear to me how I can get access to the RollingFileManager from that setup. Is there a method call that returns the RollingFileManager? Apos On Thu, Feb 4, 2016 at 4:28 PM, Ralph Goers <[email protected]> wrote: > If you are using 2.5 you can use the CronTriggeringPolicy or you can call > the RollingFileManager directly to force a Rollover. See LOG4J2-89. > > Ralph > > > On Feb 4, 2016, at 8:14 AM, Apostolis Giannakidis < > [email protected]> wrote: > > > > On a second thought, another possible way would be to extend > > TimeBasedTriggeringPolicy and create my own TimeBasedTriggeringPolicy > > pluging for the testing. Does this sound reasonable to you? > > > > On Thu, Feb 4, 2016 at 3:07 PM, Apostolis Giannakidis < > > [email protected]> wrote: > > > >> Hello all, > >> > >> My Logger uses a RollingFileAppender with a TimeBasedTriggeringPolicy. > >> > >> The file pattern is set to: > >> logfile.log.%d{yyyy-MM-dd} > >> > >> I would like to write automated functional tests that use the logger and > >> verify that the rolling of the file is performed according to the > expected > >> behavior of the TimeBasedTriggeringPolicy. > >> > >> In other words, I'd like to write a system test that does something like > >> the following: > >> 1) start the system (assuming that the current date is 2016-02-4) > >> 2) log a message. This message will be written to logfile.log. > >> 3) Verify that the message was logged to logfile.log. > >> 4) Force the log file to rotate. > >> 5) Verify that the file logfile.log.2016-02-05 was created with the > >> correct contents. > >> 6) log a message. This message will be written to logfile.log. > >> 7) Verify that the message was logged to logfile.log. > >> > >> Is there any way that I could perform step #4? > >> > >> One way that I was thinking of is if I could use my own implementation > of > >> the LogEvent that would return a fake event time for each event. > >> > >> What are your thoughts? > >> > >> Thank you very much. > >> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
