Gary,

Your sample code below isn’t modifying any LoggerConfigs to reference the new 
Appender.  How did you expect an error message to get to it?

Ralph

> On Oct 29, 2015, at 5:24 PM, Gary Gregory <[email protected]> wrote:
> 
> Yes, like I noted below, the example creates an empty file instead of a file 
> with an ERROR message.
> 
> It looks like the LoggerConfig that is in the DefaultReliabilityStrategy is 
> not updated when LoggerContext.updateLogger() is called.
> 
> I could swear I had this example working a while back. Could this be a 
> regression due to the introduction of ReliabilityStrategy?
> 
> The DefaultReliabilityStrategy is also hard coded in some LoggerConfig ctors. 
> Is that correct? Especially since we have pluggable ReliabilityStrategy 
> implementations?
> 
> Gary
> 
> 
> On Thu, Oct 29, 2015 at 5:15 PM, Ralph Goers <[email protected] 
> <mailto:[email protected]>> wrote:
> I imagine that we added more parameters to some of the methods since it was 
> first published. 
> 
> What do you mean by "it doesn’t work”? Are you getting an exception?  Since 
> no Loggers were modified to point to your new appender I am thinking all it 
> is going to do is create an empty file. This seems like a follow-on to our 
> discussion in the Jira issue about the PrintStream where you were doing the 
> same thing.
> 
> Ralph
> 
>> On Oct 29, 2015, at 4:58 PM, Gary Gregory <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>> Our nice example "Programmatically Modifying the Current Configuration after 
>> Initialization" does not work. (The PatternLayout.create() call does not 
>> compile too).
>> 
>> I've simplified it to:
>> 
>>     @Test
>>     public void test() {
>>         final LoggerContext ctx = (LoggerContext) 
>> LogManager.getContext(false);
>>         final Configuration config = ctx.getConfiguration();
>>         Layout<?> layout = PatternLayout.createDefaultLayout();
>>         Appender appender = FileAppender.createAppender("target/test.log", 
>> "false", "false", "File", "true", "false",
>>                 "false", "4000", layout, null, "false", null, config);
>>         appender.start();
>>         config.addAppender(appender);
>>         ctx.updateLoggers();
>>         LogManager.getLogger().error("FOO MSG");
>>     }
>> 
>> and it creates an empty file.
>> 
>> What am I missing? The test class has nothing else in it.
>> 
>> Gary
>> 
>> -- 
>> E-Mail: [email protected] <mailto:[email protected]> | 
>> [email protected]  <mailto:[email protected]>
>> 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 <http://garygregory.wordpress.com/> 
>> Home: http://garygregory.com/ <http://garygregory.com/>
>> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>
> 
> 
> 
> -- 
> E-Mail: [email protected] <mailto:[email protected]> | 
> [email protected]  <mailto:[email protected]>
> 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 <http://garygregory.wordpress.com/> 
> Home: http://garygregory.com/ <http://garygregory.com/>
> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>

Reply via email to