You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jesse Farinacci <ji...@gmail.com> on 2013/03/09 02:38:33 UTC

java.util.logging.SimpleFormatter vs org.apache.juli.OneLineFormatter

Greetings,

I am using Java 7, IBM JRE and Apache Tomcat 7.0.37. I am seeing a
strange difference between java.util.logging.SimpleFormatter vs
org.apache.juli.OneLineFormatter: namely, for my applications, the
SimpleFormatter will produce log records with the Class name included
but OneLineFormatter will not. The exact same application, with only
changes to the .formatter are enough to show this change.

I think this is a bug; If I use javap on my unpacked class files, I
see that they do in fact have all the debug details. Why does
OneLineFormatter show me null.null when SimpleFormatter will show the
class name? This is very frustrating, and has been going on for quite
a while..

Thank you,
-Jesse

-- 
There are 10 types of people in this world, those
that can read binary and those that can not.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: java.util.logging.SimpleFormatter vs org.apache.juli.OneLineFormatter

Posted by Konstantin Kolinko <kn...@gmail.com>.
2013/3/9 Jesse Farinacci <ji...@gmail.com>:
> Greetings,
>
> I am using Java 7, IBM JRE and Apache Tomcat 7.0.37. I am seeing a
> strange difference between java.util.logging.SimpleFormatter vs
> org.apache.juli.OneLineFormatter: namely, for my applications, the
> SimpleFormatter will produce log records with the Class name included
> but OneLineFormatter will not. The exact same application, with only
> changes to the .formatter are enough to show this change.
>
> I think this is a bug; If I use javap on my unpacked class files, I
> see that they do in fact have all the debug details. Why does
> OneLineFormatter show me null.null when SimpleFormatter will show the
> class name? This is very frustrating, and has been going on for quite
> a while..
>

File and method names are provided by JRE. Formatter only uses what is
provided to it.

        // Source
        sb.append(' ');
        sb.append(record.getSourceClassName());
        sb.append('.');
        sb.append(record.getSourceMethodName());

IIRC from reading Oracle JDK 6 sources a while ago, it throws an
exception and takes Nth record from its stacktrace.

It is a costy operation, and if the call depth is wrong (N is wrong)
or if there is no stacktrace (due to optimizations by JIT compiler)
you will not get the names.   IIRC, in some server JVMs if you throw
the same exception X times it no longer prints its stacktrace. Maybe
that is it.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: java.util.logging.SimpleFormatter vs org.apache.juli.OneLineFormatter

Posted by Jesse Farinacci <ji...@gmail.com>.
Greetings,

On Fri, Mar 8, 2013 at 8:38 PM, Jesse Farinacci <ji...@gmail.com> wrote:
> I am using Java 7, IBM JRE and Apache Tomcat 7.0.37. I am seeing a
> strange difference between java.util.logging.SimpleFormatter vs
> org.apache.juli.OneLineFormatter: namely, for my applications, the
> SimpleFormatter will produce log records with the Class name included
> but OneLineFormatter will not. The exact same application, with only
> changes to the .formatter are enough to show this change.

Thank you everyone for some good comments. I did not attach a formal
debugger, but I was able to brute force narrow down where the problem
is occurring: org.apache.juli.AsyncFileHandler. If I swap out
org.apache.juli.AsyncFileHandler with org.apache.juli.FileHandler then
the org.apache.juli.OneLineFormatter works just perfectly.

Here is the working configuration:

handlers = 1catalina.org.apache.juli.FileHandler,
2localhost.org.apache.juli.FileHandler,
3manager.org.apache.juli.FileHandler
.handlers = 1catalina.org.apache.juli.FileHandler

1catalina.org.apache.juli.FileHandler.level = ALL
1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.
1catalina.org.apache.juli.FileHandler.formatter =
org.apache.juli.OneLineFormatter

2localhost.org.apache.juli.FileHandler.level = ALL
2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.
2localhost.org.apache.juli.FileHandler.formatter =
org.apache.juli.OneLineFormatter

3manager.org.apache.juli.FileHandler.level = ALL
3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.FileHandler.prefix = manager.
3manager.org.apache.juli.FileHandler.formatter =
org.apache.juli.OneLineFormatter

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = ALL
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers
= 2localhost.org.apache.juli.FileHandler
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level
= ALL
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers
= 3manager.org.apache.juli.FileHandler

A swap to AsyncFileHandler shows the problem. Most times I see
null.null for className and methodName, but sometimes the className is
filled in and the methodName is null. So, perhaps, under heavy load,
AsyncFileHandler doesn't behave predictably with respect to some
LogRecord fields.

-Jesse

-- 
There are 10 types of people in this world, those
that can read binary and those that can not.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: java.util.logging.SimpleFormatter vs org.apache.juli.OneLineFormatter

Posted by Mark Thomas <ma...@apache.org>.
On 09/03/2013 01:38, Jesse Farinacci wrote:
> Greetings,
> 
> I am using Java 7, IBM JRE and Apache Tomcat 7.0.37. I am seeing a
> strange difference between java.util.logging.SimpleFormatter vs
> org.apache.juli.OneLineFormatter: namely, for my applications, the
> SimpleFormatter will produce log records with the Class name included
> but OneLineFormatter will not. The exact same application, with only
> changes to the .formatter are enough to show this change.
> 
> I think this is a bug; If I use javap on my unpacked class files, I
> see that they do in fact have all the debug details. Why does
> OneLineFormatter show me null.null when SimpleFormatter will show the
> class name? This is very frustrating, and has been going on for quite
> a while..

Strange. I don't see this with 7.0.x trunk and the Oracle JVM.

Looking at the source code for the two formatters the code to display
the class and method name looks identical.

In your shoes I'd be using my IDE to debug through the low writing
process step by step to figure out what is going wrong.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org