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: Testing TimeBasedTriggeringPolicy behavior
Date Thu, 04 Feb 2016 18:37:30 GMT
Added to what? The Configuration? I don’t think that is appropriate. 

Ralph

> On Feb 4, 2016, at 11:29 AM, Gary Gregory <garydgregory@gmail.com> wrote:
> 
> Would a getManager() shortcut API be helpful?
> 
> Gary
> 
> On Thu, Feb 4, 2016 at 9:16 AM, Ralph Goers <ralph.goers@dslextreme.com>
> wrote:
> 
>> Once the Configuration is created your can call getAppender(appenderName)
>> to get the RollingFileAppender. Once you have that just call the
>> getManager() method.
>> 
>> Ralph
>> 
>> 
>>> On Feb 4, 2016, at 10:03 AM, Apostolis Giannakidis <
>> ap.giannakidis@gmail.com> wrote:
>>> 
>>> 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 <ralph.goers@dslextreme.com>
>>> 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 <
>>>> ap.giannakidis@gmail.com> 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 <
>>>>> ap.giannakidis@gmail.com> 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: log4j-user-unsubscribe@logging.apache.org
>>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>>> 
>>>> 
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>> 
>> 
> 
> 
> -- 
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory



---------------------------------------------------------------------
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