You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Mikael Ståldal <mi...@magine.com> on 2015/10/23 15:36:16 UTC

null message factory?

I get this warning with Log4j 2.4.1:

was 2015-10-23 13:32:36,181 main WARN The Logger
com.magine.contenturl.ContentUrlServer$ was created with the message
factory
org.apache.logging.log4j.message.MessageFormatMessageFactory@29bf34bb and
is now requested with a null message factory (defaults to
org.apache.logging.log4j.message.ParameterizedMessageFactory), which may
create log events with unexpected formatting.

It seems to work properly though. What does it mean?

-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.staldal@magine.com
Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.

Re: null message factory?

Posted by Mikael Ståldal <mi...@magine.com>.
I have a class which does Log4j 2 logging by its own and also inheriting
from a 3rd party framework base class which does JUL logging, that's why
they use the same logger (based on class name).

(The application, and the 3rd party framework, are written in Scala.)


On Mon, Oct 26, 2015 at 5:37 PM, Ralph Goers <ra...@dslextreme.com>
wrote:

> Why would you have a single Logger being used by a class that logs with
> JUL and another class that doesn’t?  That is the only way I can see this
> happening. The formatter used is specific to the Logger.
>
> Ralph
>
>
> On Oct 26, 2015, at 8:52 AM, Mikael Ståldal <mi...@magine.com>
> wrote:
>
> Ah, that explains it.
>
> But how are you supposed to use Log4j 2 if you both use the JUL adapter
> and does logging directly through the Log4j 2 API in the same application?
>
> On Mon, Oct 26, 2015 at 2:09 PM, Ralph Goers <ra...@dslextreme.com>
> wrote:
>
>> The JUL logger does.
>>
>> Ralph
>>
>> On Oct 26, 2015, at 3:07 AM, Mikael Ståldal <mi...@magine.com>
>> wrote:
>>
>> The strange thing is that I have not called LogManager.getLogger() with
>> any MessageFormat anywhere in my app.
>>
>> I am using the JUL adapter, the Log4j 1.2 adapter and the SLF4j impl. Can
>> any of those do it?
>>
>> On Sat, Oct 24, 2015 at 1:49 AM, Remko Popma <re...@gmail.com>
>> wrote:
>>
>>> You called LogManager.getLogger(name) twice with the same name, once
>>> specifying a MessageFormat, once with just the name.
>>>
>>> When you specified just the name, you may expect to get a Logger with
>>> the default ParameterizedMessageFormat, but you're getting the cached
>>> instance with MessageFormat, so things may not work as expected.
>>>
>>> (At least I think that 's what it means.)
>>>
>>> Sent from my iPhone
>>>
>>> On 2015/10/23, at 22:36, Mikael Ståldal <mi...@magine.com>
>>> wrote:
>>>
>>> I get this warning with Log4j 2.4.1:
>>>
>>> was 2015-10-23 13:32:36,181 main WARN The Logger
>>> com.magine.contenturl.ContentUrlServer$ was created with the message
>>> factory
>>> org.apache.logging.log4j.message.MessageFormatMessageFactory@29bf34bb
>>> and is now requested with a null message factory (defaults to
>>> org.apache.logging.log4j.message.ParameterizedMessageFactory), which may
>>> create log events with unexpected formatting.
>>>
>>> It seems to work properly though. What does it mean?
>>>
>>> --
>>> [image: MagineTV]
>>>
>>> *Mikael Ståldal*
>>> Senior software developer
>>>
>>> *Magine TV*
>>> mikael.staldal@magine.com
>>> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>>>
>>> Privileged and/or Confidential Information may be contained in this
>>> message. If you are not the addressee indicated in this message
>>> (or responsible for delivery of the message to such a person), you may
>>> not copy or deliver this message to anyone. In such case,
>>> you should destroy this message and kindly notify the sender by reply
>>> email.
>>>
>>>
>>
>>
>> --
>> [image: MagineTV]
>>
>> *Mikael Ståldal*
>> Senior software developer
>>
>> *Magine TV*
>> mikael.staldal@magine.com
>> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>>
>> Privileged and/or Confidential Information may be contained in this
>> message. If you are not the addressee indicated in this message
>> (or responsible for delivery of the message to such a person), you may
>> not copy or deliver this message to anyone. In such case,
>> you should destroy this message and kindly notify the sender by reply
>> email.
>>
>>
>
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> mikael.staldal@magine.com
> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>
>
>


-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.staldal@magine.com
Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.

Re: null message factory?

Posted by Ralph Goers <ra...@dslextreme.com>.
Why would you have a single Logger being used by a class that logs with JUL and another class that doesn’t?  That is the only way I can see this happening. The formatter used is specific to the Logger.

Ralph


> On Oct 26, 2015, at 8:52 AM, Mikael Ståldal <mi...@magine.com> wrote:
> 
> Ah, that explains it.
> 
> But how are you supposed to use Log4j 2 if you both use the JUL adapter and does logging directly through the Log4j 2 API in the same application?
> 
> On Mon, Oct 26, 2015 at 2:09 PM, Ralph Goers <ralph.goers@dslextreme.com <ma...@dslextreme.com>> wrote:
> The JUL logger does.
> 
> Ralph
> 
> On Oct 26, 2015, at 3:07 AM, Mikael Ståldal <mikael.staldal@magine.com <ma...@magine.com>> wrote:
> 
>> The strange thing is that I have not called LogManager.getLogger() with any MessageFormat anywhere in my app.
>> 
>> I am using the JUL adapter, the Log4j 1.2 adapter and the SLF4j impl. Can any of those do it?
>> 
>> On Sat, Oct 24, 2015 at 1:49 AM, Remko Popma <remko.popma@gmail.com <ma...@gmail.com>> wrote:
>> You called LogManager.getLogger(name) twice with the same name, once specifying a MessageFormat, once with just the name. 
>> 
>> When you specified just the name, you may expect to get a Logger with the default ParameterizedMessageFormat, but you're getting the cached instance with MessageFormat, so things may not work as expected. 
>> 
>> (At least I think that 's what it means.)
>> 
>> Sent from my iPhone
>> 
>> On 2015/10/23, at 22:36, Mikael Ståldal <mikael.staldal@magine.com <ma...@magine.com>> wrote:
>> 
>>> I get this warning with Log4j 2.4.1:
>>> 
>>> was 2015-10-23 13:32:36,181 main WARN The Logger com.magine.contenturl.ContentUrlServer$ was created with the message factory org.apache.logging.log4j.message.MessageFormatMessageFactory@29bf34bb and is now requested with a null message factory (defaults to org.apache.logging.log4j.message.ParameterizedMessageFactory), which may create log events with unexpected formatting.
>>> 
>>> It seems to work properly though. What does it mean?
>>> 
>>> -- 
>>>  
>>> 
>>> Mikael Ståldal
>>> Senior software developer 
>>> 
>>> Magine TV
>>> mikael.staldal@magine.com <ma...@magine.com>    
>>> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com  <http://www.magine.com/>
>>> 
>>> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
>>> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case, 
>>> you should destroy this message and kindly notify the sender by reply email.   
>> 
>> 
>> 
>> -- 
>>  
>> 
>> Mikael Ståldal
>> Senior software developer 
>> 
>> Magine TV
>> mikael.staldal@magine.com <ma...@magine.com>    
>> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com  <http://www.magine.com/>
>> 
>> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
>> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case, 
>> you should destroy this message and kindly notify the sender by reply email.   
> 
> 
> 
> -- 
>  
> 
> Mikael Ståldal
> Senior software developer 
> 
> Magine TV
> mikael.staldal@magine.com <ma...@magine.com>    
> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com  <http://www.magine.com/>
> 
> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case, 
> you should destroy this message and kindly notify the sender by reply email.   


Re: null message factory?

Posted by Gary Gregory <ga...@gmail.com>.
Oops, you're right. v2:

diff --git
a/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
b/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
index 6839290..41082bb 100644
---
a/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
+++
b/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
@@ -99,14 +99,21 @@

     @Override
     public ExtendedLogger getLogger(final String name, final
MessageFactory messageFactory) {
-        final ExtendedLogger extendedLogger = loggers.get(name);
+        String key = name;
+        if (messageFactory != null) {
+            key = name + "." + messageFactory.getClass();
+        }
+        final ExtendedLogger extendedLogger = loggers.get(key);
         if (extendedLogger != null) {
             AbstractLogger.checkMessageFactory(extendedLogger,
messageFactory);
             return extendedLogger;
         }
-        loggers.putIfAbsent(name, new SimpleLogger(name, defaultLevel,
showLogName, showShortName, showDateTime,
-                showContextMap, dateTimeFormat, messageFactory, props,
stream));
-        return loggers.get(name);
+        final SimpleLogger simpleLogger = new SimpleLogger(key,
defaultLevel, showLogName, showShortName, showDateTime,
+                showContextMap, dateTimeFormat, messageFactory, props,
stream);
+        // If messageFactory was null then we need to pull it out of the
logger now
+        key = name + "." + simpleLogger.getMessageFactory().getClass();
+        loggers.putIfAbsent(key, simpleLogger);
+        return loggers.get(key);
     }

     @Override
diff --git
a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
index 6605129..228484b 100644
---
a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
+++
b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
@@ -382,14 +382,20 @@
      */
     @Override
     public Logger getLogger(final String name, final MessageFactory
messageFactory) {
-        Logger logger = loggers.get(name);
+        String key = name;
+        if (messageFactory != null) {
+            key = name + "." + messageFactory.getClass();
+        }
+        Logger logger = loggers.get(key);
         if (logger != null) {
             AbstractLogger.checkMessageFactory(logger, messageFactory);
             return logger;
         }

-        logger = newInstance(this, name, messageFactory);
-        final Logger prev = loggers.putIfAbsent(name, logger);
+        logger = newInstance(this, key, messageFactory);
+        // If messageFactory was null then we need to pull it out of the
logger now
+        key = name + "." + logger.getMessageFactory().getClass();
+        final Logger prev = loggers.putIfAbsent(key, logger);
         return prev == null ? logger : prev;
     }


Gary

On Mon, Oct 26, 2015 at 10:50 AM, Matt Sicker <bo...@gmail.com> wrote:

> Looks like you've got some inconsistency:
>
> SimpleLoggerContext:
> key = name + "." + messageFactory.getClass().getClass();
>
> LoggerContext:
> key = name + "." + messageFactory.getClass();
>
> On 26 October 2015 at 12:47, Gary Gregory <ga...@gmail.com> wrote:
>
>> Maybe something like this?
>>
>> diff --git
>> a/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
>> b/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
>> index 6839290..84ff96d 100644
>> ---
>> a/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
>> +++
>> b/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
>> @@ -99,14 +99,21 @@
>>
>>      @Override
>>      public ExtendedLogger getLogger(final String name, final
>> MessageFactory messageFactory) {
>> -        final ExtendedLogger extendedLogger = loggers.get(name);
>> +        String key = name;
>> +        if (messageFactory != null) {
>> +            key = name + "." + messageFactory.getClass().getClass();
>> +        }
>> +        final ExtendedLogger extendedLogger = loggers.get(key);
>>          if (extendedLogger != null) {
>>              AbstractLogger.checkMessageFactory(extendedLogger,
>> messageFactory);
>>              return extendedLogger;
>>          }
>> -        loggers.putIfAbsent(name, new SimpleLogger(name, defaultLevel,
>> showLogName, showShortName, showDateTime,
>> -                showContextMap, dateTimeFormat, messageFactory, props,
>> stream));
>> -        return loggers.get(name);
>> +        final SimpleLogger simpleLogger = new SimpleLogger(key,
>> defaultLevel, showLogName, showShortName, showDateTime,
>> +                showContextMap, dateTimeFormat, messageFactory, props,
>> stream);
>> +        // If messageFactory was null then we need to pull it out of the
>> logger now
>> +        key = name + "." + simpleLogger.getMessageFactory().getClass();
>> +        loggers.putIfAbsent(key, simpleLogger);
>> +        return loggers.get(key);
>>      }
>>
>>      @Override
>> diff --git
>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> index 6605129..228484b 100644
>> ---
>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> +++
>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> @@ -382,14 +382,20 @@
>>       */
>>      @Override
>>      public Logger getLogger(final String name, final MessageFactory
>> messageFactory) {
>> -        Logger logger = loggers.get(name);
>> +        String key = name;
>> +        if (messageFactory != null) {
>> +            key = name + "." + messageFactory.getClass();
>> +        }
>> +        Logger logger = loggers.get(key);
>>          if (logger != null) {
>>              AbstractLogger.checkMessageFactory(logger, messageFactory);
>>              return logger;
>>          }
>>
>> -        logger = newInstance(this, name, messageFactory);
>> -        final Logger prev = loggers.putIfAbsent(name, logger);
>> +        logger = newInstance(this, key, messageFactory);
>> +        // If messageFactory was null then we need to pull it out of the
>> logger now
>> +        key = name + "." + logger.getMessageFactory().getClass();
>> +        final Logger prev = loggers.putIfAbsent(key, logger);
>>          return prev == null ? logger : prev;
>>      }
>>
>> Some tests fail of course, the ones that check for the old behavior...
>>
>> Gary
>>
>> On Mon, Oct 26, 2015 at 10:16 AM, Gary Gregory <ga...@gmail.com>
>> wrote:
>>
>>> I see this use case:
>>>
>>> Jar A calls LogManager.getLogger("Foo", messageFactoryA);
>>> Jar B calls LogManager.getLogger("Foo", messageFactoryB);
>>>
>>> Boom!
>>>
>>> Gary
>>>
>>> On Mon, Oct 26, 2015 at 8:52 AM, Mikael Ståldal <
>>> mikael.staldal@magine.com> wrote:
>>>
>>>> Ah, that explains it.
>>>>
>>>> But how are you supposed to use Log4j 2 if you both use the JUL adapter
>>>> and does logging directly through the Log4j 2 API in the same application?
>>>>
>>>> On Mon, Oct 26, 2015 at 2:09 PM, Ralph Goers <
>>>> ralph.goers@dslextreme.com> wrote:
>>>>
>>>>> The JUL logger does.
>>>>>
>>>>> Ralph
>>>>>
>>>>> On Oct 26, 2015, at 3:07 AM, Mikael Ståldal <mi...@magine.com>
>>>>> wrote:
>>>>>
>>>>> The strange thing is that I have not called LogManager.getLogger()
>>>>> with any MessageFormat anywhere in my app.
>>>>>
>>>>> I am using the JUL adapter, the Log4j 1.2 adapter and the SLF4j impl.
>>>>> Can any of those do it?
>>>>>
>>>>> On Sat, Oct 24, 2015 at 1:49 AM, Remko Popma <re...@gmail.com>
>>>>> wrote:
>>>>>
>>>>>> You called LogManager.getLogger(name) twice with the same name, once
>>>>>> specifying a MessageFormat, once with just the name.
>>>>>>
>>>>>> When you specified just the name, you may expect to get a Logger with
>>>>>> the default ParameterizedMessageFormat, but you're getting the cached
>>>>>> instance with MessageFormat, so things may not work as expected.
>>>>>>
>>>>>> (At least I think that 's what it means.)
>>>>>>
>>>>>> Sent from my iPhone
>>>>>>
>>>>>> On 2015/10/23, at 22:36, Mikael Ståldal <mi...@magine.com>
>>>>>> wrote:
>>>>>>
>>>>>> I get this warning with Log4j 2.4.1:
>>>>>>
>>>>>> was 2015-10-23 13:32:36,181 main WARN The Logger
>>>>>> com.magine.contenturl.ContentUrlServer$ was created with the message
>>>>>> factory
>>>>>> org.apache.logging.log4j.message.MessageFormatMessageFactory@29bf34bb
>>>>>> and is now requested with a null message factory (defaults to
>>>>>> org.apache.logging.log4j.message.ParameterizedMessageFactory), which may
>>>>>> create log events with unexpected formatting.
>>>>>>
>>>>>> It seems to work properly though. What does it mean?
>>>>>>
>>>>>> --
>>>>>> [image: MagineTV]
>>>>>>
>>>>>> *Mikael Ståldal*
>>>>>> Senior software developer
>>>>>>
>>>>>> *Magine TV*
>>>>>> mikael.staldal@magine.com
>>>>>> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>>>>>>
>>>>>> Privileged and/or Confidential Information may be contained in this
>>>>>> message. If you are not the addressee indicated in this message
>>>>>> (or responsible for delivery of the message to such a person), you
>>>>>> may not copy or deliver this message to anyone. In such case,
>>>>>> you should destroy this message and kindly notify the sender by reply
>>>>>> email.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> [image: MagineTV]
>>>>>
>>>>> *Mikael Ståldal*
>>>>> Senior software developer
>>>>>
>>>>> *Magine TV*
>>>>> mikael.staldal@magine.com
>>>>> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>>>>>
>>>>> Privileged and/or Confidential Information may be contained in this
>>>>> message. If you are not the addressee indicated in this message
>>>>> (or responsible for delivery of the message to such a person), you may
>>>>> not copy or deliver this message to anyone. In such case,
>>>>> you should destroy this message and kindly notify the sender by reply
>>>>> email.
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> [image: MagineTV]
>>>>
>>>> *Mikael Ståldal*
>>>> Senior software developer
>>>>
>>>> *Magine TV*
>>>> mikael.staldal@magine.com
>>>> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>>>>
>>>> Privileged and/or Confidential Information may be contained in this
>>>> message. If you are not the addressee indicated in this message
>>>> (or responsible for delivery of the message to such a person), you may
>>>> not copy or deliver this message to anyone. In such case,
>>>> you should destroy this message and kindly notify the sender by reply
>>>> email.
>>>>
>>>
>>>
>>>
>>> --
>>> 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
>>>
>>
>>
>>
>> --
>> 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
>>
>
>
>
> --
> Matt Sicker <bo...@gmail.com>
>



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

Re: null message factory?

Posted by Matt Sicker <bo...@gmail.com>.
Looks like you've got some inconsistency:

SimpleLoggerContext:
key = name + "." + messageFactory.getClass().getClass();

LoggerContext:
key = name + "." + messageFactory.getClass();

On 26 October 2015 at 12:47, Gary Gregory <ga...@gmail.com> wrote:

> Maybe something like this?
>
> diff --git
> a/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
> b/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
> index 6839290..84ff96d 100644
> ---
> a/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
> +++
> b/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
> @@ -99,14 +99,21 @@
>
>      @Override
>      public ExtendedLogger getLogger(final String name, final
> MessageFactory messageFactory) {
> -        final ExtendedLogger extendedLogger = loggers.get(name);
> +        String key = name;
> +        if (messageFactory != null) {
> +            key = name + "." + messageFactory.getClass().getClass();
> +        }
> +        final ExtendedLogger extendedLogger = loggers.get(key);
>          if (extendedLogger != null) {
>              AbstractLogger.checkMessageFactory(extendedLogger,
> messageFactory);
>              return extendedLogger;
>          }
> -        loggers.putIfAbsent(name, new SimpleLogger(name, defaultLevel,
> showLogName, showShortName, showDateTime,
> -                showContextMap, dateTimeFormat, messageFactory, props,
> stream));
> -        return loggers.get(name);
> +        final SimpleLogger simpleLogger = new SimpleLogger(key,
> defaultLevel, showLogName, showShortName, showDateTime,
> +                showContextMap, dateTimeFormat, messageFactory, props,
> stream);
> +        // If messageFactory was null then we need to pull it out of the
> logger now
> +        key = name + "." + simpleLogger.getMessageFactory().getClass();
> +        loggers.putIfAbsent(key, simpleLogger);
> +        return loggers.get(key);
>      }
>
>      @Override
> diff --git
> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
> index 6605129..228484b 100644
> ---
> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
> +++
> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
> @@ -382,14 +382,20 @@
>       */
>      @Override
>      public Logger getLogger(final String name, final MessageFactory
> messageFactory) {
> -        Logger logger = loggers.get(name);
> +        String key = name;
> +        if (messageFactory != null) {
> +            key = name + "." + messageFactory.getClass();
> +        }
> +        Logger logger = loggers.get(key);
>          if (logger != null) {
>              AbstractLogger.checkMessageFactory(logger, messageFactory);
>              return logger;
>          }
>
> -        logger = newInstance(this, name, messageFactory);
> -        final Logger prev = loggers.putIfAbsent(name, logger);
> +        logger = newInstance(this, key, messageFactory);
> +        // If messageFactory was null then we need to pull it out of the
> logger now
> +        key = name + "." + logger.getMessageFactory().getClass();
> +        final Logger prev = loggers.putIfAbsent(key, logger);
>          return prev == null ? logger : prev;
>      }
>
> Some tests fail of course, the ones that check for the old behavior...
>
> Gary
>
> On Mon, Oct 26, 2015 at 10:16 AM, Gary Gregory <ga...@gmail.com>
> wrote:
>
>> I see this use case:
>>
>> Jar A calls LogManager.getLogger("Foo", messageFactoryA);
>> Jar B calls LogManager.getLogger("Foo", messageFactoryB);
>>
>> Boom!
>>
>> Gary
>>
>> On Mon, Oct 26, 2015 at 8:52 AM, Mikael Ståldal <
>> mikael.staldal@magine.com> wrote:
>>
>>> Ah, that explains it.
>>>
>>> But how are you supposed to use Log4j 2 if you both use the JUL adapter
>>> and does logging directly through the Log4j 2 API in the same application?
>>>
>>> On Mon, Oct 26, 2015 at 2:09 PM, Ralph Goers <ralph.goers@dslextreme.com
>>> > wrote:
>>>
>>>> The JUL logger does.
>>>>
>>>> Ralph
>>>>
>>>> On Oct 26, 2015, at 3:07 AM, Mikael Ståldal <mi...@magine.com>
>>>> wrote:
>>>>
>>>> The strange thing is that I have not called LogManager.getLogger() with
>>>> any MessageFormat anywhere in my app.
>>>>
>>>> I am using the JUL adapter, the Log4j 1.2 adapter and the SLF4j impl.
>>>> Can any of those do it?
>>>>
>>>> On Sat, Oct 24, 2015 at 1:49 AM, Remko Popma <re...@gmail.com>
>>>> wrote:
>>>>
>>>>> You called LogManager.getLogger(name) twice with the same name, once
>>>>> specifying a MessageFormat, once with just the name.
>>>>>
>>>>> When you specified just the name, you may expect to get a Logger with
>>>>> the default ParameterizedMessageFormat, but you're getting the cached
>>>>> instance with MessageFormat, so things may not work as expected.
>>>>>
>>>>> (At least I think that 's what it means.)
>>>>>
>>>>> Sent from my iPhone
>>>>>
>>>>> On 2015/10/23, at 22:36, Mikael Ståldal <mi...@magine.com>
>>>>> wrote:
>>>>>
>>>>> I get this warning with Log4j 2.4.1:
>>>>>
>>>>> was 2015-10-23 13:32:36,181 main WARN The Logger
>>>>> com.magine.contenturl.ContentUrlServer$ was created with the message
>>>>> factory
>>>>> org.apache.logging.log4j.message.MessageFormatMessageFactory@29bf34bb
>>>>> and is now requested with a null message factory (defaults to
>>>>> org.apache.logging.log4j.message.ParameterizedMessageFactory), which may
>>>>> create log events with unexpected formatting.
>>>>>
>>>>> It seems to work properly though. What does it mean?
>>>>>
>>>>> --
>>>>> [image: MagineTV]
>>>>>
>>>>> *Mikael Ståldal*
>>>>> Senior software developer
>>>>>
>>>>> *Magine TV*
>>>>> mikael.staldal@magine.com
>>>>> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>>>>>
>>>>> Privileged and/or Confidential Information may be contained in this
>>>>> message. If you are not the addressee indicated in this message
>>>>> (or responsible for delivery of the message to such a person), you may
>>>>> not copy or deliver this message to anyone. In such case,
>>>>> you should destroy this message and kindly notify the sender by reply
>>>>> email.
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> [image: MagineTV]
>>>>
>>>> *Mikael Ståldal*
>>>> Senior software developer
>>>>
>>>> *Magine TV*
>>>> mikael.staldal@magine.com
>>>> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>>>>
>>>> Privileged and/or Confidential Information may be contained in this
>>>> message. If you are not the addressee indicated in this message
>>>> (or responsible for delivery of the message to such a person), you may
>>>> not copy or deliver this message to anyone. In such case,
>>>> you should destroy this message and kindly notify the sender by reply
>>>> email.
>>>>
>>>>
>>>
>>>
>>> --
>>> [image: MagineTV]
>>>
>>> *Mikael Ståldal*
>>> Senior software developer
>>>
>>> *Magine TV*
>>> mikael.staldal@magine.com
>>> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>>>
>>> Privileged and/or Confidential Information may be contained in this
>>> message. If you are not the addressee indicated in this message
>>> (or responsible for delivery of the message to such a person), you may
>>> not copy or deliver this message to anyone. In such case,
>>> you should destroy this message and kindly notify the sender by reply
>>> email.
>>>
>>
>>
>>
>> --
>> 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
>>
>
>
>
> --
> 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
>



-- 
Matt Sicker <bo...@gmail.com>

Re: null message factory?

Posted by Gary Gregory <ga...@gmail.com>.
Maybe something like this?

diff --git
a/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
b/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
index 6839290..84ff96d 100644
---
a/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
+++
b/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
@@ -99,14 +99,21 @@

     @Override
     public ExtendedLogger getLogger(final String name, final
MessageFactory messageFactory) {
-        final ExtendedLogger extendedLogger = loggers.get(name);
+        String key = name;
+        if (messageFactory != null) {
+            key = name + "." + messageFactory.getClass().getClass();
+        }
+        final ExtendedLogger extendedLogger = loggers.get(key);
         if (extendedLogger != null) {
             AbstractLogger.checkMessageFactory(extendedLogger,
messageFactory);
             return extendedLogger;
         }
-        loggers.putIfAbsent(name, new SimpleLogger(name, defaultLevel,
showLogName, showShortName, showDateTime,
-                showContextMap, dateTimeFormat, messageFactory, props,
stream));
-        return loggers.get(name);
+        final SimpleLogger simpleLogger = new SimpleLogger(key,
defaultLevel, showLogName, showShortName, showDateTime,
+                showContextMap, dateTimeFormat, messageFactory, props,
stream);
+        // If messageFactory was null then we need to pull it out of the
logger now
+        key = name + "." + simpleLogger.getMessageFactory().getClass();
+        loggers.putIfAbsent(key, simpleLogger);
+        return loggers.get(key);
     }

     @Override
diff --git
a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
index 6605129..228484b 100644
---
a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
+++
b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
@@ -382,14 +382,20 @@
      */
     @Override
     public Logger getLogger(final String name, final MessageFactory
messageFactory) {
-        Logger logger = loggers.get(name);
+        String key = name;
+        if (messageFactory != null) {
+            key = name + "." + messageFactory.getClass();
+        }
+        Logger logger = loggers.get(key);
         if (logger != null) {
             AbstractLogger.checkMessageFactory(logger, messageFactory);
             return logger;
         }

-        logger = newInstance(this, name, messageFactory);
-        final Logger prev = loggers.putIfAbsent(name, logger);
+        logger = newInstance(this, key, messageFactory);
+        // If messageFactory was null then we need to pull it out of the
logger now
+        key = name + "." + logger.getMessageFactory().getClass();
+        final Logger prev = loggers.putIfAbsent(key, logger);
         return prev == null ? logger : prev;
     }

Some tests fail of course, the ones that check for the old behavior...

Gary

On Mon, Oct 26, 2015 at 10:16 AM, Gary Gregory <ga...@gmail.com>
wrote:

> I see this use case:
>
> Jar A calls LogManager.getLogger("Foo", messageFactoryA);
> Jar B calls LogManager.getLogger("Foo", messageFactoryB);
>
> Boom!
>
> Gary
>
> On Mon, Oct 26, 2015 at 8:52 AM, Mikael Ståldal <mikael.staldal@magine.com
> > wrote:
>
>> Ah, that explains it.
>>
>> But how are you supposed to use Log4j 2 if you both use the JUL adapter
>> and does logging directly through the Log4j 2 API in the same application?
>>
>> On Mon, Oct 26, 2015 at 2:09 PM, Ralph Goers <ra...@dslextreme.com>
>> wrote:
>>
>>> The JUL logger does.
>>>
>>> Ralph
>>>
>>> On Oct 26, 2015, at 3:07 AM, Mikael Ståldal <mi...@magine.com>
>>> wrote:
>>>
>>> The strange thing is that I have not called LogManager.getLogger() with
>>> any MessageFormat anywhere in my app.
>>>
>>> I am using the JUL adapter, the Log4j 1.2 adapter and the SLF4j impl.
>>> Can any of those do it?
>>>
>>> On Sat, Oct 24, 2015 at 1:49 AM, Remko Popma <re...@gmail.com>
>>> wrote:
>>>
>>>> You called LogManager.getLogger(name) twice with the same name, once
>>>> specifying a MessageFormat, once with just the name.
>>>>
>>>> When you specified just the name, you may expect to get a Logger with
>>>> the default ParameterizedMessageFormat, but you're getting the cached
>>>> instance with MessageFormat, so things may not work as expected.
>>>>
>>>> (At least I think that 's what it means.)
>>>>
>>>> Sent from my iPhone
>>>>
>>>> On 2015/10/23, at 22:36, Mikael Ståldal <mi...@magine.com>
>>>> wrote:
>>>>
>>>> I get this warning with Log4j 2.4.1:
>>>>
>>>> was 2015-10-23 13:32:36,181 main WARN The Logger
>>>> com.magine.contenturl.ContentUrlServer$ was created with the message
>>>> factory
>>>> org.apache.logging.log4j.message.MessageFormatMessageFactory@29bf34bb
>>>> and is now requested with a null message factory (defaults to
>>>> org.apache.logging.log4j.message.ParameterizedMessageFactory), which may
>>>> create log events with unexpected formatting.
>>>>
>>>> It seems to work properly though. What does it mean?
>>>>
>>>> --
>>>> [image: MagineTV]
>>>>
>>>> *Mikael Ståldal*
>>>> Senior software developer
>>>>
>>>> *Magine TV*
>>>> mikael.staldal@magine.com
>>>> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>>>>
>>>> Privileged and/or Confidential Information may be contained in this
>>>> message. If you are not the addressee indicated in this message
>>>> (or responsible for delivery of the message to such a person), you may
>>>> not copy or deliver this message to anyone. In such case,
>>>> you should destroy this message and kindly notify the sender by reply
>>>> email.
>>>>
>>>>
>>>
>>>
>>> --
>>> [image: MagineTV]
>>>
>>> *Mikael Ståldal*
>>> Senior software developer
>>>
>>> *Magine TV*
>>> mikael.staldal@magine.com
>>> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>>>
>>> Privileged and/or Confidential Information may be contained in this
>>> message. If you are not the addressee indicated in this message
>>> (or responsible for delivery of the message to such a person), you may
>>> not copy or deliver this message to anyone. In such case,
>>> you should destroy this message and kindly notify the sender by reply
>>> email.
>>>
>>>
>>
>>
>> --
>> [image: MagineTV]
>>
>> *Mikael Ståldal*
>> Senior software developer
>>
>> *Magine TV*
>> mikael.staldal@magine.com
>> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>>
>> Privileged and/or Confidential Information may be contained in this
>> message. If you are not the addressee indicated in this message
>> (or responsible for delivery of the message to such a person), you may
>> not copy or deliver this message to anyone. In such case,
>> you should destroy this message and kindly notify the sender by reply
>> email.
>>
>
>
>
> --
> 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
>



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

Re: null message factory?

Posted by Gary Gregory <ga...@gmail.com>.
I see this use case:

Jar A calls LogManager.getLogger("Foo", messageFactoryA);
Jar B calls LogManager.getLogger("Foo", messageFactoryB);

Boom!

Gary

On Mon, Oct 26, 2015 at 8:52 AM, Mikael Ståldal <mi...@magine.com>
wrote:

> Ah, that explains it.
>
> But how are you supposed to use Log4j 2 if you both use the JUL adapter
> and does logging directly through the Log4j 2 API in the same application?
>
> On Mon, Oct 26, 2015 at 2:09 PM, Ralph Goers <ra...@dslextreme.com>
> wrote:
>
>> The JUL logger does.
>>
>> Ralph
>>
>> On Oct 26, 2015, at 3:07 AM, Mikael Ståldal <mi...@magine.com>
>> wrote:
>>
>> The strange thing is that I have not called LogManager.getLogger() with
>> any MessageFormat anywhere in my app.
>>
>> I am using the JUL adapter, the Log4j 1.2 adapter and the SLF4j impl. Can
>> any of those do it?
>>
>> On Sat, Oct 24, 2015 at 1:49 AM, Remko Popma <re...@gmail.com>
>> wrote:
>>
>>> You called LogManager.getLogger(name) twice with the same name, once
>>> specifying a MessageFormat, once with just the name.
>>>
>>> When you specified just the name, you may expect to get a Logger with
>>> the default ParameterizedMessageFormat, but you're getting the cached
>>> instance with MessageFormat, so things may not work as expected.
>>>
>>> (At least I think that 's what it means.)
>>>
>>> Sent from my iPhone
>>>
>>> On 2015/10/23, at 22:36, Mikael Ståldal <mi...@magine.com>
>>> wrote:
>>>
>>> I get this warning with Log4j 2.4.1:
>>>
>>> was 2015-10-23 13:32:36,181 main WARN The Logger
>>> com.magine.contenturl.ContentUrlServer$ was created with the message
>>> factory
>>> org.apache.logging.log4j.message.MessageFormatMessageFactory@29bf34bb
>>> and is now requested with a null message factory (defaults to
>>> org.apache.logging.log4j.message.ParameterizedMessageFactory), which may
>>> create log events with unexpected formatting.
>>>
>>> It seems to work properly though. What does it mean?
>>>
>>> --
>>> [image: MagineTV]
>>>
>>> *Mikael Ståldal*
>>> Senior software developer
>>>
>>> *Magine TV*
>>> mikael.staldal@magine.com
>>> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>>>
>>> Privileged and/or Confidential Information may be contained in this
>>> message. If you are not the addressee indicated in this message
>>> (or responsible for delivery of the message to such a person), you may
>>> not copy or deliver this message to anyone. In such case,
>>> you should destroy this message and kindly notify the sender by reply
>>> email.
>>>
>>>
>>
>>
>> --
>> [image: MagineTV]
>>
>> *Mikael Ståldal*
>> Senior software developer
>>
>> *Magine TV*
>> mikael.staldal@magine.com
>> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>>
>> Privileged and/or Confidential Information may be contained in this
>> message. If you are not the addressee indicated in this message
>> (or responsible for delivery of the message to such a person), you may
>> not copy or deliver this message to anyone. In such case,
>> you should destroy this message and kindly notify the sender by reply
>> email.
>>
>>
>
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> mikael.staldal@magine.com
> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>



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

Re: null message factory?

Posted by Gary Gregory <ga...@gmail.com>.
Do we need to make the logger cache key be the logger name plus the message
factory name?

Gary
On Oct 26, 2015 8:52 AM, "Mikael Ståldal" <mi...@magine.com> wrote:

> Ah, that explains it.
>
> But how are you supposed to use Log4j 2 if you both use the JUL adapter
> and does logging directly through the Log4j 2 API in the same application?
>
> On Mon, Oct 26, 2015 at 2:09 PM, Ralph Goers <ra...@dslextreme.com>
> wrote:
>
>> The JUL logger does.
>>
>> Ralph
>>
>> On Oct 26, 2015, at 3:07 AM, Mikael Ståldal <mi...@magine.com>
>> wrote:
>>
>> The strange thing is that I have not called LogManager.getLogger() with
>> any MessageFormat anywhere in my app.
>>
>> I am using the JUL adapter, the Log4j 1.2 adapter and the SLF4j impl. Can
>> any of those do it?
>>
>> On Sat, Oct 24, 2015 at 1:49 AM, Remko Popma <re...@gmail.com>
>> wrote:
>>
>>> You called LogManager.getLogger(name) twice with the same name, once
>>> specifying a MessageFormat, once with just the name.
>>>
>>> When you specified just the name, you may expect to get a Logger with
>>> the default ParameterizedMessageFormat, but you're getting the cached
>>> instance with MessageFormat, so things may not work as expected.
>>>
>>> (At least I think that 's what it means.)
>>>
>>> Sent from my iPhone
>>>
>>> On 2015/10/23, at 22:36, Mikael Ståldal <mi...@magine.com>
>>> wrote:
>>>
>>> I get this warning with Log4j 2.4.1:
>>>
>>> was 2015-10-23 13:32:36,181 main WARN The Logger
>>> com.magine.contenturl.ContentUrlServer$ was created with the message
>>> factory
>>> org.apache.logging.log4j.message.MessageFormatMessageFactory@29bf34bb
>>> and is now requested with a null message factory (defaults to
>>> org.apache.logging.log4j.message.ParameterizedMessageFactory), which may
>>> create log events with unexpected formatting.
>>>
>>> It seems to work properly though. What does it mean?
>>>
>>> --
>>> [image: MagineTV]
>>>
>>> *Mikael Ståldal*
>>> Senior software developer
>>>
>>> *Magine TV*
>>> mikael.staldal@magine.com
>>> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>>>
>>> Privileged and/or Confidential Information may be contained in this
>>> message. If you are not the addressee indicated in this message
>>> (or responsible for delivery of the message to such a person), you may
>>> not copy or deliver this message to anyone. In such case,
>>> you should destroy this message and kindly notify the sender by reply
>>> email.
>>>
>>>
>>
>>
>> --
>> [image: MagineTV]
>>
>> *Mikael Ståldal*
>> Senior software developer
>>
>> *Magine TV*
>> mikael.staldal@magine.com
>> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>>
>> Privileged and/or Confidential Information may be contained in this
>> message. If you are not the addressee indicated in this message
>> (or responsible for delivery of the message to such a person), you may
>> not copy or deliver this message to anyone. In such case,
>> you should destroy this message and kindly notify the sender by reply
>> email.
>>
>>
>
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> mikael.staldal@magine.com
> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>

Re: null message factory?

Posted by Mikael Ståldal <mi...@magine.com>.
Ah, that explains it.

But how are you supposed to use Log4j 2 if you both use the JUL adapter and
does logging directly through the Log4j 2 API in the same application?

On Mon, Oct 26, 2015 at 2:09 PM, Ralph Goers <ra...@dslextreme.com>
wrote:

> The JUL logger does.
>
> Ralph
>
> On Oct 26, 2015, at 3:07 AM, Mikael Ståldal <mi...@magine.com>
> wrote:
>
> The strange thing is that I have not called LogManager.getLogger() with
> any MessageFormat anywhere in my app.
>
> I am using the JUL adapter, the Log4j 1.2 adapter and the SLF4j impl. Can
> any of those do it?
>
> On Sat, Oct 24, 2015 at 1:49 AM, Remko Popma <re...@gmail.com>
> wrote:
>
>> You called LogManager.getLogger(name) twice with the same name, once
>> specifying a MessageFormat, once with just the name.
>>
>> When you specified just the name, you may expect to get a Logger with the
>> default ParameterizedMessageFormat, but you're getting the cached instance
>> with MessageFormat, so things may not work as expected.
>>
>> (At least I think that 's what it means.)
>>
>> Sent from my iPhone
>>
>> On 2015/10/23, at 22:36, Mikael Ståldal <mi...@magine.com>
>> wrote:
>>
>> I get this warning with Log4j 2.4.1:
>>
>> was 2015-10-23 13:32:36,181 main WARN The Logger
>> com.magine.contenturl.ContentUrlServer$ was created with the message
>> factory
>> org.apache.logging.log4j.message.MessageFormatMessageFactory@29bf34bb
>> and is now requested with a null message factory (defaults to
>> org.apache.logging.log4j.message.ParameterizedMessageFactory), which may
>> create log events with unexpected formatting.
>>
>> It seems to work properly though. What does it mean?
>>
>> --
>> [image: MagineTV]
>>
>> *Mikael Ståldal*
>> Senior software developer
>>
>> *Magine TV*
>> mikael.staldal@magine.com
>> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>>
>> Privileged and/or Confidential Information may be contained in this
>> message. If you are not the addressee indicated in this message
>> (or responsible for delivery of the message to such a person), you may
>> not copy or deliver this message to anyone. In such case,
>> you should destroy this message and kindly notify the sender by reply
>> email.
>>
>>
>
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> mikael.staldal@magine.com
> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>
>


-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.staldal@magine.com
Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.

Re: null message factory?

Posted by Ralph Goers <ra...@dslextreme.com>.
The JUL logger does.

Ralph

> On Oct 26, 2015, at 3:07 AM, Mikael Ståldal <mi...@magine.com> wrote:
> 
> The strange thing is that I have not called LogManager.getLogger() with any MessageFormat anywhere in my app.
> 
> I am using the JUL adapter, the Log4j 1.2 adapter and the SLF4j impl. Can any of those do it?
> 
>> On Sat, Oct 24, 2015 at 1:49 AM, Remko Popma <re...@gmail.com> wrote:
>> You called LogManager.getLogger(name) twice with the same name, once specifying a MessageFormat, once with just the name. 
>> 
>> When you specified just the name, you may expect to get a Logger with the default ParameterizedMessageFormat, but you're getting the cached instance with MessageFormat, so things may not work as expected. 
>> 
>> (At least I think that 's what it means.)
>> 
>> Sent from my iPhone
>> 
>>> On 2015/10/23, at 22:36, Mikael Ståldal <mi...@magine.com> wrote:
>>> 
>>> I get this warning with Log4j 2.4.1:
>>> 
>>> was 2015-10-23 13:32:36,181 main WARN The Logger com.magine.contenturl.ContentUrlServer$ was created with the message factory org.apache.logging.log4j.message.MessageFormatMessageFactory@29bf34bb and is now requested with a null message factory (defaults to org.apache.logging.log4j.message.ParameterizedMessageFactory), which may create log events with unexpected formatting.
>>> 
>>> It seems to work properly though. What does it mean?
>>> 
>>> -- 
>>>  
>>> 
>>> Mikael Ståldal
>>> Senior software developer 
>>> 
>>> Magine TV
>>> mikael.staldal@magine.com    
>>> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com 
>>> 
>>> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
>>> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case, 
>>> you should destroy this message and kindly notify the sender by reply email.   
> 
> 
> 
> -- 
>  
> 
> Mikael Ståldal
> Senior software developer 
> 
> Magine TV
> mikael.staldal@magine.com    
> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com 
> 
> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case, 
> you should destroy this message and kindly notify the sender by reply email.   

Re: null message factory?

Posted by Mikael Ståldal <mi...@magine.com>.
The strange thing is that I have not called LogManager.getLogger() with any
MessageFormat anywhere in my app.

I am using the JUL adapter, the Log4j 1.2 adapter and the SLF4j impl. Can
any of those do it?

On Sat, Oct 24, 2015 at 1:49 AM, Remko Popma <re...@gmail.com> wrote:

> You called LogManager.getLogger(name) twice with the same name, once
> specifying a MessageFormat, once with just the name.
>
> When you specified just the name, you may expect to get a Logger with the
> default ParameterizedMessageFormat, but you're getting the cached instance
> with MessageFormat, so things may not work as expected.
>
> (At least I think that 's what it means.)
>
> Sent from my iPhone
>
> On 2015/10/23, at 22:36, Mikael Ståldal <mi...@magine.com> wrote:
>
> I get this warning with Log4j 2.4.1:
>
> was 2015-10-23 13:32:36,181 main WARN The Logger
> com.magine.contenturl.ContentUrlServer$ was created with the message
> factory
> org.apache.logging.log4j.message.MessageFormatMessageFactory@29bf34bb and
> is now requested with a null message factory (defaults to
> org.apache.logging.log4j.message.ParameterizedMessageFactory), which may
> create log events with unexpected formatting.
>
> It seems to work properly though. What does it mean?
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> mikael.staldal@magine.com
> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>
>


-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.staldal@magine.com
Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.

Re: null message factory?

Posted by Remko Popma <re...@gmail.com>.
You called LogManager.getLogger(name) twice with the same name, once specifying a MessageFormat, once with just the name. 

When you specified just the name, you may expect to get a Logger with the default ParameterizedMessageFormat, but you're getting the cached instance with MessageFormat, so things may not work as expected. 

(At least I think that 's what it means.)

Sent from my iPhone

> On 2015/10/23, at 22:36, Mikael Ståldal <mi...@magine.com> wrote:
> 
> I get this warning with Log4j 2.4.1:
> 
> was 2015-10-23 13:32:36,181 main WARN The Logger com.magine.contenturl.ContentUrlServer$ was created with the message factory org.apache.logging.log4j.message.MessageFormatMessageFactory@29bf34bb and is now requested with a null message factory (defaults to org.apache.logging.log4j.message.ParameterizedMessageFactory), which may create log events with unexpected formatting.
> 
> It seems to work properly though. What does it mean?
> 
> -- 
>  
> 
> Mikael Ståldal
> Senior software developer 
> 
> Magine TV
> mikael.staldal@magine.com    
> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com 
> 
> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case, 
> you should destroy this message and kindly notify the sender by reply email.