struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Huber <gregh3...@gmail.com>
Subject Re: Upgrade to tiles 3 jcl-over-slf4j
Date Fri, 29 Jan 2016 17:14:17 GMT
Yes, if you are logging directly to log4j2 but if other jars use slf4j you
need to delegate the logging (create a log4j2.xml if upgrading from v1,
note the format is also different!)


<dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.14</version>
</dependency>
<dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
            <version>2.5</version>
</dependency>

Cheers Greg


######################################
here is what i use, via Jakarta Commons Logging JCL.

(.....although my velocity is logging to the console!)

<dependencies>
    <!-- Jakarta Commons Logging JCL -->
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.2</version>
    </dependency>

    <!-- Actual Logging Implementation log4j 2 -->
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.5</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.5</version>
    </dependency>

    <!-- Logging redirects -->
    <!-- log4j 2 Jakarta Commons Logging JCL Bridge -->
    <!-- If existing components use Apache Commons Logging 1.x will
delegate
        all Jakarta Commons Logging JCL Log4j 2 -->
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-jcl</artifactId>
        <version>2.5</version>
    </dependency>
    <!-- SLF4J Bridge -->
    <!-- If existing components use SLF4J and you want to have this logging
        routed to Log4j 2 -->
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-slf4j-impl</artifactId>
        <version>2.5</version>
    </dependency>

    <!-- slf4j Logging -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.14</version>
    </dependency>
    <!-- SLF4J Bridge. Not used see above log directly to Log4j 2 -->
    <!-- slf4j bridge to Jakarta Commons Logging JCL and will delegate all
SLF4J
        logging to Jakarta Commons Logging JCL. -->
    <!-- <dependency> <groupId>org.slf4j</groupId>
<artifactId>slf4j-jcl</artifactId>
        <version>1.7.14</version> </dependency -->
</dependencies>

<Configuration>

    <Properties>
        <Property name="log-path">${sys:catalina.home}/logs</Property>
    </Properties>

    <Appenders>

        <RollingFile name="RollingFile" fileName="${log-path}/events.log"
            filePattern="${log-path}/events-%d{yyyy-MM-dd}-%i.log">

            <PatternLayout>
                <pattern>%d %-5p %c %C{1}:%M - %m%n</pattern>
            </PatternLayout>

            <Policies>
                <TimeBasedTriggeringPolicy /><!-- Rotated everyday -->
                <SizeBasedTriggeringPolicy size="999KB" />
            </Policies>

            <DefaultRolloverStrategy max="3" />
        </RollingFile>

    </Appenders>

    <Loggers>

        <Root level="ERROR" additivity="false">
            <AppenderRef ref="RollingFile" />
        </Root>

    </Loggers>

</Configuration>

On 29 January 2016 at 16:48, Martin Gainty <mgainty@hotmail.com> wrote:

> Hi Greg-
>
> can you confirm these dependencies for log4j?
>
>   <dependencies>    <dependency>
> <groupId>org.apache.logging.log4j</groupId>
> <artifactId>log4j-api</artifactId>      <version>2.5</version>
>     </dependency>    <dependency>
> <groupId>org.apache.logging.log4j</groupId>
> <artifactId>log4j-core</artifactId>      <version>2.5</version>
> </dependency>    <dependency>      <groupId>junit</groupId>
> <artifactId>junit</artifactId>      <version>4.9</version>
> <scope>test</scope>    </dependency>  </dependencies>
> Thanks!
> Martin
> ______________________________________________
>
>
>
> > Date: Fri, 29 Jan 2016 16:04:18 +0000
> > Subject: Re: Upgrade to tiles 3 jcl-over-slf4j
> > From: gregh3269@gmail.com
> > To: dev@struts.apache.org
> >
> > Well, I currently log with commons, but to get struts logging working I
> > have had to upgrade to v2 and use the log4j2.xml file.
> >
> > Also a good idea to bypass the commons for slf4j and go directly.
> >
> > Cheers Greg
> >
> >
> >
> > On 29 January 2016 at 15:07, Christoph Nenning <
> > Christoph.Nenning@lex-com.net> wrote:
> >
> > > > Should jcl-over-slf4j be in the tiles-core pom?
> > > >
> > >
> > > I see that it is currently the case but I do not need it.
> > >
> > >
> > > > <snip />
> > > > slf4j-jcl is used to delegate all SLF4J logging to Commons Logging.
> > > > <snip />
> > > > ​and then log4j-jcl to delegate all to Commons Logging to log4j 2
> > >
> > > SLF4J can be forwarded to log4j 2 directly with log4j-slf4j-impl.
> There is
> > > no need to include Commons Logging (if you don't need it for other
> reasons
> > > than forwarding).
> > >
> > >  <dependency>
> > >        <groupId>org.apache.logging.log4j</groupId>
> > >        <artifactId>log4j-slf4j-impl</artifactId>
> > >  </dependency>
> > >
> > >
> > >
> > > Regards,
> > > Christoph
> > >
> > >
> > >
> > > > It seems to be an option for migrating from Jakarta Commons Logging
> > > which
> > > > some might not want to do.
> > > >
> > > > <dependency>
> > > >       <groupId>org.slf4j</groupId>
> > > >       <artifactId>jcl-over-slf4j</artifactId>
> > > > </dependency>
> > > >
> > > >
> > > > ​http://www.slf4j.org/legacy.html​
> > > >
> > > > ​To ease migration to SLF4J from JCL​
> > > >
> > > > ​#####​
> > > >
> > > > ​I use ​Jakarta Commons Logging.
> > > >
> > > >
> > > > slf4j-jcl is used to delegate all SLF4J logging to Commons Logging.
> > > >
> > > > ​<dependency>
> > > >       <groupId>org.slf4j</groupId>
> > > >       <artifactId>slf4j-jcl</artifactId>
> > > > </dependency>​
> > > >
> > > >
> > > > ​and then log4j-jcl to delegate all to Commons Logging to log4j 2
> > > >
> > > > <dependency>
> > > >             <groupId>org.apache.logging.log4j</groupId>
> > > >             <artifactId>log4j-jcl</artifactId>
> > > >             <version>2.5</version>
> > > > </dependency>​
> > > >
> > > >
> > > >
> > > > Cheers Greg.
> > >
> > >
> > > This Email was scanned by Sophos Anti Virus
> > >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message