Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #39934 > unrolled thread

How do you log your Java?

Started by"e.d.pro...@gmail.com" <e.d.programmer@gmail.com>
First post2023-03-20 06:31 -0700
Last post2023-03-20 10:11 -0400
Articles 4 — 2 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  How do you log your Java? "e.d.pro...@gmail.com" <e.d.programmer@gmail.com> - 2023-03-20 06:31 -0700
    Re: How do you log your Java? Arne Vajhøj <arne@vajhoej.dk> - 2023-03-20 09:59 -0400
      Re: How do you log your Java? "e.d.pro...@gmail.com" <e.d.programmer@gmail.com> - 2023-03-20 07:05 -0700
        Re: How do you log your Java? Arne Vajhøj <arne@vajhoej.dk> - 2023-03-20 10:11 -0400

#39934 — How do you log your Java?

From"e.d.pro...@gmail.com" <e.d.programmer@gmail.com>
Date2023-03-20 06:31 -0700
SubjectHow do you log your Java?
Message-ID<962b2d02-2056-4d40-b7a9-d2730831e349n@googlegroups.com>
Do you use log4j2 or something else?

How do you redirect the catalina logs to a file? If I have log4j2.xml in the tomcat folder, it appears to be ignoring the log4j2.xml in the application folder.

Do you use log4j2.xml?  This appears to be the popular setup, but the last application I worked with had many different project for pieces of the one big application, so I put them all under one master project and had the spring framework call the API to configure on startup, seemed easier than using xml files especially if the sub-projects can share and would each need their own xml file.

Do you use the static method at the start of each class Logger log = LoggerFactory.getLogger() or the @Log4j2 annotation, or is there another better way?

[toc] | [next] | [standalone]


#39935

FromArne Vajhøj <arne@vajhoej.dk>
Date2023-03-20 09:59 -0400
Message-ID<tv9ora$3i8e5$1@dont-email.me>
In reply to#39934
On 3/20/2023 9:31 AM, e.d.pro...@gmail.com wrote:
> Do you use log4j2 or something else?
> 
> How do you redirect the catalina logs to a file? If I have log4j2.xml
> in the tomcat folder, it appears to be ignoring the log4j2.xml in the
> application folder.
> 
> Do you use log4j2.xml?  This appears to be the popular setup, but the
> last application I worked with had many different project for pieces
> of the one big application, so I put them all under one master
> project and had the spring framework call the API to configure on
> startup, seemed easier than using xml files especially if the
> sub-projects can share and would each need their own xml file.
> 
> Do you use the static method at the start of each class Logger log =
> LoggerFactory.getLogger() or the @Log4j2 annotation, or is there
> another better way?

I believe the popularity ranking is:
1) logback
2) log4j 2.x
3) jul
4) log4j 1.x (obsolete, deprecated)

The big benefit of configuration files over programmatic
configuration is that it allows operations to change logging
without requiring help from software engineering.

@Log4j2 annotation is a Lombok feature I believe, so only
a possibility for those using Lombok.

Arne

[toc] | [prev] | [next] | [standalone]


#39936

From"e.d.pro...@gmail.com" <e.d.programmer@gmail.com>
Date2023-03-20 07:05 -0700
Message-ID<25b108ad-ea16-4b59-ba4e-3660336349d8n@googlegroups.com>
In reply to#39935
> I believe the popularity ranking is: 
> 1) logback 
> 2) log4j 2.x 
> 3) jul 
> 4) log4j 1.x (obsolete, deprecated) 

What is logback? I've seen this and thought it was just an older version of the log4j.
I haven't heard of a jul logging.

> The big benefit of configuration files over programmatic 
> configuration is that it allows operations to change logging 
> without requiring help from software engineering. 

You can use the API to set up log4j configuration and read configuration from something someone other than the developer can edit.

> @Log4j2 annotation is a Lombok feature I believe, so only 
> a possibility for those using Lombok. 
> 
> Arne

Is the annotation just a shorter version of that one line factory statement or is there another benefit?

[toc] | [prev] | [next] | [standalone]


#39937

FromArne Vajhøj <arne@vajhoej.dk>
Date2023-03-20 10:11 -0400
Message-ID<tv9pi9$3i8e5$2@dont-email.me>
In reply to#39936
On 3/20/2023 10:05 AM, e.d.pro...@gmail.com wrote:
>> I believe the popularity ranking is:
>> 1) logback
>> 2) log4j 2.x
>> 3) jul
>> 4) log4j 1.x (obsolete, deprecated)
> 
> What is logback? I've seen this and thought it was just an older version of the log4j.
> I haven't heard of a jul logging.

https://logback.qos.ch/

It is different from but similar to log4j.

>> @Log4j2 annotation is a Lombok feature I believe, so only
>> a possibility for those using Lombok.
> 
> Is the annotation just a shorter version of that one line factory statement or is there another benefit?

I don't use Lombok, but:

https://projectlombok.org/api/lombok/extern/log4j/Log4j

says:

<quote>
  Example:

  @Log4j
  public class LogExample {
  }


will generate:

  public class LogExample {
      private static final org.apache.log4j.Logger log = 
org.apache.log4j.Logger.getLogger(LogExample.class);
  }
  </quote>

Arne



[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web