Re: Using Log4J2 2.8 (via the 1.2 API Bridge) for Tomcat8 Internal Logging - RollingFileAppender does not (cannot?) create new Log File

2017-04-13 Thread Ankit Agarwal

 

On Thursday, April 13, 2017 8:58 AM, shivashankar manukondu 
 wrote:
 

 Hi,
If you do not have any concern to use Timebased then you can try this option 
and also working with Log4J2.

Thanks Siva. I'll try this out and see what happens.

Regards,Siva
On Thu, Apr 13, 2017 at 5:21 PM, Ankit Agarwal 
 wrote:





    On Thursday, April 13, 2017 7:43 AM, "Berneburg, Cris J. - US" 
 wrote:


 Ankit

-Original Message-
From: Berneburg, Cris J. - US
Sent: Thursday, April 13, 2017 10:35 AM
To: Tomcat Users List
Subject: RE: Using Log4J2 2.8 (via the 1.2 API Bridge) for Tomcat8 Internal 
Logging - RollingFileAppender does not (cannot?) create new Log File

>> The only problem is that Tomcat only supports the Log4J
>> 1.x API. It doesn't natively support Log4J2 so we have
>> to use the 1.x -> 2.x Bridge and some things do not work.
>
> OK, can you get it basically working with the older Log4J
> instead, without the fancy stuff, just to investigate?
>
> Also, I don't know the interface between Tomcat/Log4J.  I
> would have guessed that Log4J would need to conform to the
> Apache Commons Logging API, not the other way around.  But
> again, I'm new to this.

Below is something interesting that Mark Thomas (current Tomcat maintainer) has 
to say about Tomcat and Log4J/2:

-Original Message-
From: Mark Thomas [mailto:ma...@apache.org]
Sent: Tuesday, April 11, 2017 1:22 PM
To: Tomcat Users List
Subject: Re: tomcat-embed-logging-juli not updated in Maven Central?

> log4j is no longer supported. Its replacement, log4j2, can
> hook directly into the java.util.logging framework. Therefore,
> there is no need for the separate modules. The classes from
> the tomcat-embed-logging-juli JAR were merged into the core JAR.

Thanks for your reply Cris. The note from Mark is interesting.
However, I couldn't find any instructions on how to get Log4J2 working 
natively, i.e., without the 1.x -> 2.x Bridge. The Tomcat documentation hasn't 
been updated either.
I'd be happy to test out Log4J2 native logging in Tomcat as well as document 
the same, if someone can point me to how to set this up.

Thanks,Ankit


--
Cris Berneburg
CACI Lead Software Engineer

 Т� �� 
��ХF�V�7V'67&��R��� âW6W'2�V�7V'67&���6B�6�R��& 
pФf�"FF�F6G2�R���âW6W' 2ֆV�F��6B�6�R��Р

   



-- 
 
RegardsSiva#068860592040

   

Re: Using Log4J2 2.8 (via the 1.2 API Bridge) for Tomcat8 Internal Logging - RollingFileAppender does not (cannot?) create new Log File

2017-04-13 Thread shivashankar manukondu
Hi,

If you do not have any concern to use Timebased then you can try this
option and also working with Log4J2.



Regards,
Siva

On Thu, Apr 13, 2017 at 5:21 PM, Ankit Agarwal <
ankit_agar...@yahoo.com.invalid> wrote:

>
>
>
>
> On Thursday, April 13, 2017 7:43 AM, "Berneburg, Cris J. - US" <
> cberneb...@caci.com> wrote:
>
>
>  Ankit
>
> -Original Message-
> From: Berneburg, Cris J. - US
> Sent: Thursday, April 13, 2017 10:35 AM
> To: Tomcat Users List
> Subject: RE: Using Log4J2 2.8 (via the 1.2 API Bridge) for Tomcat8
> Internal Logging - RollingFileAppender does not (cannot?) create new Log
> File
>
> >> The only problem is that Tomcat only supports the Log4J
> >> 1.x API. It doesn't natively support Log4J2 so we have
> >> to use the 1.x -> 2.x Bridge and some things do not work.
> >
> > OK, can you get it basically working with the older Log4J
> > instead, without the fancy stuff, just to investigate?
> >
> > Also, I don't know the interface between Tomcat/Log4J.  I
> > would have guessed that Log4J would need to conform to the
> > Apache Commons Logging API, not the other way around.  But
> > again, I'm new to this.
>
> Below is something interesting that Mark Thomas (current Tomcat
> maintainer) has to say about Tomcat and Log4J/2:
>
> -Original Message-
> From: Mark Thomas [mailto:ma...@apache.org]
> Sent: Tuesday, April 11, 2017 1:22 PM
> To: Tomcat Users List
> Subject: Re: tomcat-embed-logging-juli not updated in Maven Central?
>
> > log4j is no longer supported. Its replacement, log4j2, can
> > hook directly into the java.util.logging framework. Therefore,
> > there is no need for the separate modules. The classes from
> > the tomcat-embed-logging-juli JAR were merged into the core JAR.
>
> Thanks for your reply Cris. The note from Mark is interesting.
> However, I couldn't find any instructions on how to get Log4J2 working
> natively, i.e., without the 1.x -> 2.x Bridge. The Tomcat documentation
> hasn't been updated either.
> I'd be happy to test out Log4J2 native logging in Tomcat as well as
> document the same, if someone can point me to how to set this up.
>
> Thanks,Ankit
>
>
> --
> Cris Berneburg
> CACI Lead Software Engineer
>
>  ���
> ��ХF�V�7V'67&��R���âW6W'2�V�7V'67&���6B�6�R��&
> pФf�"FF�F6G2�R���âW6W'2ֆV�F��6B�6�R��Р
>
>




-- 

Regards
Siva
#068860592040


Re: Using Log4J2 2.8 (via the 1.2 API Bridge) for Tomcat8 Internal Logging - RollingFileAppender does not (cannot?) create new Log File

2017-04-13 Thread Ankit Agarwal




On Thursday, April 13, 2017 7:43 AM, "Berneburg, Cris J. - US" 
 wrote:
 

 Ankit

-Original Message-
From: Berneburg, Cris J. - US 
Sent: Thursday, April 13, 2017 10:35 AM
To: Tomcat Users List
Subject: RE: Using Log4J2 2.8 (via the 1.2 API Bridge) for Tomcat8 Internal 
Logging - RollingFileAppender does not (cannot?) create new Log File

>> The only problem is that Tomcat only supports the Log4J
>> 1.x API. It doesn't natively support Log4J2 so we have
>> to use the 1.x -> 2.x Bridge and some things do not work.
>
> OK, can you get it basically working with the older Log4J
> instead, without the fancy stuff, just to investigate?
>
> Also, I don't know the interface between Tomcat/Log4J.  I
> would have guessed that Log4J would need to conform to the
> Apache Commons Logging API, not the other way around.  But
> again, I'm new to this.

Below is something interesting that Mark Thomas (current Tomcat maintainer) has 
to say about Tomcat and Log4J/2:

-Original Message-
From: Mark Thomas [mailto:ma...@apache.org] 
Sent: Tuesday, April 11, 2017 1:22 PM
To: Tomcat Users List
Subject: Re: tomcat-embed-logging-juli not updated in Maven Central?

> log4j is no longer supported. Its replacement, log4j2, can
> hook directly into the java.util.logging framework. Therefore,
> there is no need for the separate modules. The classes from
> the tomcat-embed-logging-juli JAR were merged into the core JAR.

Thanks for your reply Cris. The note from Mark is interesting.
However, I couldn't find any instructions on how to get Log4J2 working 
natively, i.e., without the 1.x -> 2.x Bridge. The Tomcat documentation hasn't 
been updated either.
I'd be happy to test out Log4J2 native logging in Tomcat as well as document 
the same, if someone can point me to how to set this up.

Thanks,Ankit


--
Cris Berneburg
CACI Lead Software Engineer
 
 
Т�ХF�V�7V'67&��R���âW6W'2�V�7V'67&���6B�6�R��Фf�"FF�F6G2�R���âW6W'2ֆV�F��6B�6�R��Р

   

RE: Using Log4J2 2.8 (via the 1.2 API Bridge) for Tomcat8 Internal Logging - RollingFileAppender does not (cannot?) create new Log File

2017-04-13 Thread Berneburg, Cris J. - US
Ankit

-Original Message-
From: Berneburg, Cris J. - US 
Sent: Thursday, April 13, 2017 10:35 AM
To: Tomcat Users List
Subject: RE: Using Log4J2 2.8 (via the 1.2 API Bridge) for Tomcat8 Internal 
Logging - RollingFileAppender does not (cannot?) create new Log File

>> The only problem is that Tomcat only supports the Log4J
>> 1.x API. It doesn't natively support Log4J2 so we have
>> to use the 1.x -> 2.x Bridge and some things do not work.
>
> OK, can you get it basically working with the older Log4J
> instead, without the fancy stuff, just to investigate?
>
> Also, I don't know the interface between Tomcat/Log4J.  I
> would have guessed that Log4J would need to conform to the
> Apache Commons Logging API, not the other way around.  But
> again, I'm new to this.

Below is something interesting that Mark Thomas (current Tomcat maintainer) has 
to say about Tomcat and Log4J/2:

-Original Message-
From: Mark Thomas [mailto:ma...@apache.org] 
Sent: Tuesday, April 11, 2017 1:22 PM
To: Tomcat Users List
Subject: Re: tomcat-embed-logging-juli not updated in Maven Central?

> log4j is no longer supported. Its replacement, log4j2, can
> hook directly into the java.util.logging framework. Therefore,
> there is no need for the separate modules. The classes from
> the tomcat-embed-logging-juli JAR were merged into the core JAR.

--
Cris Berneburg
CACI Lead Software Engineer
 


RE: Using Log4J2 2.8 (via the 1.2 API Bridge) for Tomcat8 Internal Logging - RollingFileAppender does not (cannot?) create new Log File

2017-04-13 Thread Berneburg, Cris J. - US
Hi Ankit

-Original Message-
From: Ankit Agarwal [mailto:ankit_agarwal@...] 
Sent: Tuesday, April 11, 2017 12:28 PM
To: Tomcat Users List
Subject: Re: Using Log4J2 2.8 (via the 1.2 API Bridge) for Tomcat8 Internal 
Logging - RollingFileAppender does not (cannot?) create new Log File

> Hi Cris,
>
> 1. No worries. All thoughts and questions are welcome
> because it helps me think too :)

OK good.  I'm still learning about this also.  :-)

Just a friendly FYI, it is considered polite and in "good form" to intersperse 
your comments within the message segments to which they apply in your reply.  
That way those reading can easily maintain the context of the conversation in 
their minds.  IOW, please don't "top post".  :-)

> 2. You can replace the java.utils.logging entirely with
> Log4J in Tomcat. See the link I posted in my very first
> email. The Tomcat documentation provides the steps.

I knew it was possible, but I have not done that and don't know what the 
restrictions and gotchas are.

> The only problem is that Tomcat only supports the Log4J
> 1.x API. It doesn't natively support Log4J2 so we have
> to use the 1.x -> 2.x Bridge and some things do not work.

OK, can you get it basically working with the older Log4J instead, without the 
fancy stuff, just to investigate?

Also, I don't know the interface between Tomcat/Log4J.  I would have guessed 
that Log4J would need to conform to the Apache Commons Logging API, not the 
other way around.  But again, I'm new to this.

> E.g., I've found that the bridge does not support the
> "Delete" directive within the "DefaultRolloverStrategy",
> hence I have to delete the old zipped Tomcat logs with a
> script myself -  More likely this is because "Delete" is a
> Log4J2 construct that Tomcat doesn't know about yet I'm
> replacing the internal logging of Tomcat so, e.g., the
> catalina log files and the localhost log files are written
> by Log4J instead of the standard java.util.logging Log4J2
> works great within the WARs I deploy.

Sorry, I'm gonna have to plead ignorance here.  If Tomcat is delegating the 
responsibility of logging to Log4J, then why would Tomcat need to know anything 
about a delete operation, since Log4J is "handling the details"?

Is there any way you could simplify your configuration to experiment, then add 
complexity in stages to see where it breaks down?  IOW, start simple, get that 
working, add another option, and repeat?  You might notice something during the 
process.

> 3. The problem is that, for me when the first log-able event
> occurs after the old log file is zipped, a new log file is
> not created by the Tomcat Log4J. Instead nothing is logged
> and operations just fail. E.g., once the old log file has
> been zipped, if I try to deploy a new WAR, it just fails
> because there is no place to log messages (since the new log
> file was not created).

I know this may sound like a "catch-22 situation", but what, if any, error 
messages are you getting?  Is there a stack trace?  I see that you have a 
Console appender configured that might be able to display errors.  I wonder if 
that can be used to display errors from within the logging mechanism itself.

> Once I restart Tomcat, everything works fine. It seems
> that the Tomcat Log4J only rolls over to a new file (i.e.,
> creates it) on startup and not while its running.

--
Cris Berneburg
CACI Lead Software Engineer
 


Re: Using Log4J2 2.8 (via the 1.2 API Bridge) for Tomcat8 Internal Logging - RollingFileAppender does not (cannot?) create new Log File

2017-04-11 Thread Ankit Agarwal
Hi Cris,
1. No worries. All thoughts and questions are welcome because it helps me think 
too :)
2. You can replace the java.utils.logging entirely with Log4J in Tomcat. See 
the link I posted in my very first email. The Tomcat documentation provides the 
steps.The only problem is that Tomcat only supports the Log4J 1.x API. It 
doesn't natively support Log4J2 so we have to use the 1.x -> 2.x Bridge and 
some things do not work. E.g., I've found that the bridge does not support the 
"Delete" directive within the "DefaultRolloverStrategy", hence I have to delete 
the old zipped Tomcat logs with a script myself -  More likely this is because 
"Delete" is a Log4J2 construct that Tomcat doesn't know about yet
I'm replacing the internal logging of Tomcat so, e.g., the catalina log files 
and the localhost log files are written by Log4J instead of the standard 
java.util.logging
Log4J2 works great within the WARs I deploy.
3. The problem is that, for me when the first log-able event occurs after the 
old log file is zipped, a new log file is not created by the Tomcat Log4J. 
Instead nothing is logged and operations just fail. E.g., once the old log file 
has been zipped, if I try to deploy a new WAR, it just fails because there is 
no place to log messages (since the new log file was not created).
Once I restart Tomcat, everything works fine. It seems that the Tomcat Log4J 
only rolls over to a new file (i.e., creates it) on startup and not while its 
running.

Ankit


On Tuesday, April 11, 2017 7:41 AM, "Berneburg, Cris J. - US" 
 wrote:
 

 Ankit

-Original Message-
From: Ankit Agarwal [mailto:ankit_agarwal@...] 
Sent: Monday, April 10, 2017 3:24 PM
To: users@tomcat.apache.org
Subject: Using Log4J2 2.8 (via the 1.2 API Bridge) for Tomcat8 Internal Logging 
- RollingFileAppender does not (cannot?) create new Log File

> Hi,
>
> I’m using Log4J2 (2.8) via the 1.2 API Bridge for Tomcat 8 internal logging.
>
> I followed the instructions here:
> https://tomcat.apache.org/tomcat-8.0-doc/logging.html#Using_Log4j
> 
> - With the exception that I also copied the Bridge JAR into the Tomcat8 lib 
> directory
>
> I have configured Log4J2 with this XML file
>
> 
> 
>      
>          ${sys:catalina.base}/logs
>          CMS
>          Tomcat
>          ${env:PUBLIC_IP_ADDRESS}
>          
>          %d{DATE} "%d{ISO8601}" "${systemName}" 
>"${componentName}" "%X{clientIpAddress}" "%X{clientTcpPort}" "%X{username}" 
>"%X{sessionId}" "%X{sessionAuthenticationId}" "%X{sessionAuthenticationToken}" 
>"${serverIpAddress}" "%T" "%t" "%X{apiName}" "%X{apiSystemActionType}" 
>"%X{apiSystemItemType}" "%x" "%l" "%p" "%m"%n%n
>      
>      
>          
>                
>          
>          filePattern="${logDirectory}/catalina-%i.log.gz">
>                
>                
>                    
>                
>                
>          
>          fileName="${logDirectory}/localhost.log" 
>filePattern="${logDirectory}/localhost-%i.log.gz">
>                
>                
>                    
>                
>                
>          
>          filePattern="${logDirectory}/manager-%i.log.gz">
>                
>                
>                    
>                
>                
>          
>          fileName="${logDirectory}/host-manager.log" 
>filePattern="${logDirectory}/host-manager-%i.log.gz">
>                
>                
>                    
>                
>                
>          
>      
>      
>          
>                
>          
>          name="org.apache.catalina.core.ContainerBase.[Catalina].[localhost]" 
>level="info" additivity="false">
>                
>          
>          name="org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager]"
> level="info" additivity="false">
>                
>          
>          name="org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager]"
> level="info" additivity="false">
>                
>          
>      
> 
>
> All 4 RollingFile Appenders are configured identically (except for
> the log filename).
>
> The problem I’m running into is that when the
> SizeBasedTriggeringPolicy is executed, the current log file is
> zipped. However, a new log file is not created.
>
> As a result, the Tomcat8 stops logging.
>
> If I restart Tomcat8, then a new file is created and the Tomcat8
> functions normally, but only until this new log file reaches its
> limit and is zipped up. Then once again, the problem repeats itself.
>
> Does the 1.2 API Bridge / Tomcat 8 not support the
> SizeBasedTriggeringPolicy?
>
> Do I have any options other than restarting the Tomcat8? Will the
> TimeBasedTriggeringPolicy work and is that my only option?
>
> Since the Log4J2 being used in Tomcat8 has no problem creating the
> required files on restart, I don’t think its a permissions issue.
>
> I’d appreciate any thoughts and 

RE: Using Log4J2 2.8 (via the 1.2 API Bridge) for Tomcat8 Internal Logging - RollingFileAppender does not (cannot?) create new Log File

2017-04-11 Thread Berneburg, Cris J. - US
Ankit

-Original Message-
From: Ankit Agarwal [mailto:ankit_agarwal@...] 
Sent: Monday, April 10, 2017 3:24 PM
To: users@tomcat.apache.org
Subject: Using Log4J2 2.8 (via the 1.2 API Bridge) for Tomcat8 Internal Logging 
- RollingFileAppender does not (cannot?) create new Log File

> Hi,
>
> I’m using Log4J2 (2.8) via the 1.2 API Bridge for Tomcat 8 internal logging.
>
> I followed the instructions here:
> https://tomcat.apache.org/tomcat-8.0-doc/logging.html#Using_Log4j
> 
> - With the exception that I also copied the Bridge JAR into the Tomcat8 lib 
> directory
>
> I have configured Log4J2 with this XML file
>
> 
> 
>  
>   ${sys:catalina.base}/logs
>   CMS
>   Tomcat
>   ${env:PUBLIC_IP_ADDRESS}
>   
>   %d{DATE} "%d{ISO8601}" "${systemName}" 
> "${componentName}" "%X{clientIpAddress}" "%X{clientTcpPort}" "%X{username}" 
> "%X{sessionId}" "%X{sessionAuthenticationId}" 
> "%X{sessionAuthenticationToken}" "${serverIpAddress}" "%T" "%t" "%X{apiName}" 
> "%X{apiSystemActionType}" "%X{apiSystemItemType}" "%x" "%l" "%p" 
> "%m"%n%n
>  
>  
>   
>
>   
>fileName="${logDirectory}/catalina.log" 
> filePattern="${logDirectory}/catalina-%i.log.gz">
>
>
> 
>
>
>   
>fileName="${logDirectory}/localhost.log" 
> filePattern="${logDirectory}/localhost-%i.log.gz">
>
>
> 
>
>
>   
>filePattern="${logDirectory}/manager-%i.log.gz">
>
>
> 
>
>
>   
>fileName="${logDirectory}/host-manager.log" 
> filePattern="${logDirectory}/host-manager-%i.log.gz">
>
>
> 
>
>
>   
>  
>  
>   
>
>   
>name="org.apache.catalina.core.ContainerBase.[Catalina].[localhost]" 
> level="info" additivity="false">
>
>   
>name="org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager]"
>  level="info" additivity="false">
>
>   
>name="org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager]"
>  level="info" additivity="false">
>
>   
>  
> 
>
> All 4 RollingFile Appenders are configured identically (except for
> the log filename).
>
> The problem I’m running into is that when the
> SizeBasedTriggeringPolicy is executed, the current log file is
> zipped. However, a new log file is not created.
>
> As a result, the Tomcat8 stops logging.
>
> If I restart Tomcat8, then a new file is created and the Tomcat8
> functions normally, but only until this new log file reaches its
> limit and is zipped up. Then once again, the problem repeats itself.
>
> Does the 1.2 API Bridge / Tomcat 8 not support the
> SizeBasedTriggeringPolicy?
>
> Do I have any options other than restarting the Tomcat8? Will the
> TimeBasedTriggeringPolicy work and is that my only option?
>
> Since the Log4J2 being used in Tomcat8 has no problem creating the
> required files on restart, I don’t think its a permissions issue.
>
> I’d appreciate any thoughts and pointers.
>
> Thanks,
> Ankit

3 things:

1. Sorry, I cannot answer your questions directly cuz I'm kind of newbie in 
this arena.

2. Are you allowed to overwrite what log files that Tomcat would generate 
anyway?  We use Log4J2 to create custom log files and leave the 
Tomcat-generated ones alone.  Maybe our configuration is a little wacky.  :-)

3. In my (very limited) experience, Log4J2 creates a new log file only when the 
first log-able event actually happens.  IOW, it won't create an empty log file 
without actually having something to log.

Please let us know what you learn and how you progress in solving the issue!

--
Cris Berneburg
CACI Lead Software Engineer


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



Using Log4J2 2.8 (via the 1.2 API Bridge) for Tomcat8 Internal Logging - RollingFileAppender does not (cannot?) create new Log File

2017-04-10 Thread Ankit Agarwal
Hi,

I’m using Log4J2 (2.8) via the 1.2 API Bridge for Tomcat 8 internal logging.

I followed the instructions here: 
https://tomcat.apache.org/tomcat-8.0-doc/logging.html#Using_Log4j 

- With the exception that I also copied the Bridge JAR into the Tomcat8 lib 
directory

I have configured Log4J2 with this XML file



 
  ${sys:catalina.base}/logs
  CMS
  Tomcat
  ${env:PUBLIC_IP_ADDRESS}
  
  %d{DATE} "%d{ISO8601}" "${systemName}" 
"${componentName}" "%X{clientIpAddress}" "%X{clientTcpPort}" "%X{username}" 
"%X{sessionId}" "%X{sessionAuthenticationId}" "%X{sessionAuthenticationToken}" 
"${serverIpAddress}" "%T" "%t" "%X{apiName}" "%X{apiSystemActionType}" 
"%X{apiSystemItemType}" "%x" "%l" "%p" "%m"%n%n
 
 
  
   
  
  
   
   

   
   
  
  
   
   

   
   
  
  
   
   

   
   
  
  
   
   

   
   
  
 
 
  
   
  
  
   
  
  
   
  
  
   
  
 



All 4 RollingFile Appenders are configured identically (except for the log 
filename).

The problem I’m running into is that when the SizeBasedTriggeringPolicy is 
executed, the current log file is zipped. However, a new log file is not 
created.

As a result, the Tomcat8 stops logging.

If I restart Tomcat8, then a new file is created and the Tomcat8 functions 
normally, but only until this new log file reaches its limit and is zipped up. 
Then once again, the problem repeats itself.

Does the 1.2 API Bridge / Tomcat 8 not support the SizeBasedTriggeringPolicy?

Do I have any options other than restarting the Tomcat8? Will the 
TimeBasedTriggeringPolicy work and is that my only option?

Since the Log4J2 being used in Tomcat8 has no problem creating the required 
files on restart, I don’t think its a permissions issue.

I’d appreciate any thoughts and pointers.

Thanks,
Ankit