Tomcat7 logging hell - why two different formats coming out? - linux

My logging.properties in Eclipse looked like this when I initially posted this question:
handlers = java.util.logging.ConsoleHandler
org.apache.catalina.core=OFF
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format=JUL %4$s: %2$s%n%4$s: %5$s%n
I am also encountering the same issue on a Linux server with this configuration:
handlers = 2localhost.org.apache.juli.FileHandler, org.apache.juli.FileHandler
.handlers = org.apache.juli.FileHandler
2localhost.org.apache.juli.FileHandler.level = INFO
2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.
org.apache.juli.FileHandler.level = ALL
org.apache.juli.FileHandler.formatter = java.util.logging.SimpleFormatter
org.apache.juli.FileHandler.directory = ${catalina.base}/logs
java.util.logging.SimpleFormatter.format=tomcat: %4$s: %2$s%n%4$s: %5$s%n
org.apache.catalina.handlers = org.apache.juli.FileHandler
org.apache.catalina.startup.level = SEVERE
org.apache.catalina.session.ManagerBase.level = SEVERE
org.apache.catalina.core.AprLifecycleListener.level=SEVERE
org.apache.catalina.connector.level = SEVERE
org.apache.coyote.level=SEVERE
org.apache.catalina.level=ALL
org.apache.catalina.startup.HostConfig.level = SEVERE
org.apache.catalina.loader.WebappClassLoader.level = SEVERE
org.apache.catalina.session.ManagerBase.level = INFO
# ServletContext logger
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].formatter = java.util.logging.SimpleFormatter
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].format=servlet: %4$s: %2$s%n%4$s: %5$s%n
Why then does my console log in Eclipse look like this?
JUL INFO: org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.8.0_05\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;c:\Program Files (x86)\Intel\iCLS Client\;c:\Program Files\Intel\iCLS Client\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Bitvise SSH Client;C:\Program Files (x86)\MySQL\MySQL Utilities 1.4.3\;C:\Program Files (x86)\MySQL\MySQL Utilities 1.4.3\Doctrine extensions for PHP\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\TortoiseGit\bin;C:\Program Files (x86)\Git\cmd;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;C:\Program Files (x86)\BaseX\bin;C:\Program Files (x86)\WinMerge;C:\Program Files (x86)\Skype\Phone\;.
JUL WARNING: org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:ctc_web_front_ui' did not find a matching property.
JUL INFO: org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
JUL INFO: org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
JUL INFO: org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 359 ms
JUL INFO: org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
JUL INFO: org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
JUL INFO: org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
JUL INFO: org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'servletSpringDispatcher'
JUL INFO: org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'servletSpringDispatcher': initialization started
Where are the bare INFO messages coming from?
And why are catalina.core messages still showing up even though I set them to OFF?
On the Linux server the JULI log looks like this:
tomcat: FINE: org.apache.catalina.core.ContainerBase addChildInternal
FINE: Add child StandardHost[localhost] StandardEngine[Catalina]
tomcat: FINE: org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for [StandardServer[8005]] to [INITIALIZING]
tomcat: FINE: org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for [org.apache.catalina.deploy.NamingResources#13fee20c] to [INITIALIZING]
tomcat: FINE: org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for [org.apache.catalina.deploy.NamingResources#13fee20c] to [INITIALIZED]
tomcat: FINE: org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for [StandardService[Catalina]] to [INITIALIZING]
tomcat: FINE: org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for [StandardEngine[Catalina]] to [INITIALIZING]
tomcat: FINE: org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for [StandardEngine[Catalina]] to [INITIALIZED]
tomcat: FINE: org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for [Connector[HTTP/1.1-8080]] to [INITIALIZING]
tomcat: FINE: org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for [org.apache.catalina.connector.MapperListener#737996a0] to [INITIALIZING]
tomcat: FINE: org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for [org.apache.catalina.connector.MapperListener#737996a0] to [INITIALIZED]
tomcat: FINE: org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for [Connector[HTTP/1.1-8080]] to [INITIALIZED]
tomcat: FINE: org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for [StandardService[Catalina]] to [INITIALIZED]
tomcat: FINE: org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for [StandardServer[8005]] to [INITIALIZED]
tomcat: FINE: org.apache.catalina.util.LifecycleBase setStateInternal
FINE: Setting state for [StandardServer[8005]] to [STARTING_PREP]
tomcat: FINE: org.apache.catalina.core.NamingContextListener lifecycleEvent
FINE: Bound StandardServer[8005]
tomcat: FINE: org.apache.catalina.core.NamingContextListener createNamingContext
FINE: Creating JNDI naming context
tomcat: FINE: org.apache.catalina.core.NamingContextListener addResource
Same question applies, why don't all lines start with tomcat:?
UPDATE
While debugging I discovered that BOTH LINES of each log entry come from java.util.logging.Logger.logp()

My logging.properties in Eclipse
I do not know how your workspace is configured. Maybe that file is not used at all.
Java Logging is configured by system properties.
You need one property (-Djava.util.logging.manager) to configure org.apache.juli.ClassLoaderLogManager as log manager implementation for Java Logging.
You need other property (-Djava.util.logging.config.file) to configure path to the configuration file.
Usually both properties are set by the launch script (catalina.sh, catalina.bat), but Eclipse launches java directly, without a help from that script, so those system properties have to be set explicitly in a launch configuration.
http://tomcat.markmail.org/thread/vpr7mjxmgdvkl3dv
Tomcat JULI supports per-classloader configuration of logging.
This feature allows one to configure logging individually for each web application by packing a WEB-INF/classes/logging.properties file with it.
If you have unexpectedly placed a logging.properties file into classpath, it will have the same effect: it will supersede the default configuration for classes loaded by that classloader.
E.g. it is known that some version of Jollyday library (4 years ago) included an unexpected logging.properties file that enabled FINE logging.
.level = ALL
https://bz.apache.org/bugzilla/show_bug.cgi?id=52011

The answer has been staring us in the face, from the top of the posting:
java.util.logging.SimpleFormatter.format=JUL %4$s: %2$s%n%4$s: %5$s%n
^^^^^^^
The extra %n%4$s: in the format string is what causes the additional line to show up. Duh.

The info messages you are referring to is not actually part of core. They are being generated by classes in different packages. By dissecting catalina libs and identifying the classes responsible for particular logs, here is the configuration which has prevented logs on tomcat 7.0.63, by appending to default logging.properties:
org.apache.catalina.startup.level=OFF
org.apache.catalina.startup.handlers=1catalina.org.apache.juli.FileHandler.level
org.apache.catalina.core.level=OFF
org.apache.catalina.core.handlers=1catalina.org.apache.juli.FileHandler.level
org.apache.coyote.level=OFF
org.apache.coyote.handlers=1catalina.org.apache.juli.FileHandler.level

I think you're missing jul-to-slf4j. See here for more detail slf4j legacy bridge documentation

Related

Dot Net Core application, hosted on IIS, crashes when the system restart

I have created a .NET core 5.0 project and published it. Then I hosted it on IIS. Whenever the system restarts, my application crashes. Logs after crashing are as follows:
[aspnetcorev2_inprocess.dll] Initializing logs for 'C:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App\5.0.6\aspnetcorev2_inprocess.dll'. Process Id: 3364.. File Version: 15.0.21113.6. Description: IIS ASP.NET Core Module V2 Request Handler. Commit: dc5e11abdb05b322f4b74b3afbcfb352fe984b2e.
[aspnetcorev2_inprocess.dll] Waiting for initialization
[aspnetcorev2_inprocess.dll] Starting in-process worker thread
[aspnetcorev2_inprocess.dll] Resolving hostfxr parameters for application: '.\FaxApi.exe' arguments: '' path: 'C:\inetpub\wwwroot\FaxApi\'
[aspnetcorev2_inprocess.dll] Known dotnet.exe location: 'C:\Program Files (x86)\dotnet\dotnet.exe'
[aspnetcorev2_inprocess.dll] Process path '.\FaxApi.exe' is not dotnet, treating application as standalone or portable with bootstrapper
[aspnetcorev2_inprocess.dll] Checking application.dll at 'C:\inetpub\wwwroot\FaxApi\.\FaxApi.dll'
[aspnetcorev2_inprocess.dll] Checking hostfxr.dll at 'C:\inetpub\wwwroot\FaxApi\.\hostfxr.dll'
[aspnetcorev2_inprocess.dll] hostfxr.dll found app local at 'C:\inetpub\wwwroot\FaxApi\.\hostfxr.dll', treating application as portable with launcher
[aspnetcorev2_inprocess.dll] Resolving absolute path to hostfxr.dll from 'C:\Program Files (x86)\dotnet\dotnet.exe'
[aspnetcorev2_inprocess.dll] hostfxr.dll located at 'C:\Program Files (x86)\dotnet\host\fxr\5.0.6\hostfxr.dll'
[aspnetcorev2_inprocess.dll] Parsed hostfxr options: dotnet location: 'C:\Program Files (x86)\dotnet\dotnet.exe' hostfxr path: 'C:\Program Files (x86)\dotnet\host\fxr\5.0.6\hostfxr.dll' arguments:
[aspnetcorev2_inprocess.dll] Argument[0] = 'C:\Program Files (x86)\dotnet\dotnet.exe'
[aspnetcorev2_inprocess.dll] Argument[1] = 'C:\inetpub\wwwroot\FaxApi\.\FaxApi.dll'
[aspnetcorev2_inprocess.dll] Setting environment variable ASPNETCORE_ENVIRONMENT=Production
[aspnetcorev2_inprocess.dll] Setting environment variable ASPNETCORE_IIS_HTTPAUTH=windows;anonymous;
[aspnetcorev2_inprocess.dll] Setting environment variable ASPNETCORE_IIS_PHYSICAL_PATH=C:\inetpub\wwwroot\FaxApi\
[aspnetcorev2_inprocess.dll] Loading hostfxr from location C:\Program Files (x86)\dotnet\host\fxr\5.0.6\hostfxr.dll
[aspnetcorev2_inprocess.dll] Initial Dll directory: '', current directory: 'C:\Windows\SysWOW64\inetsrv'
[aspnetcorev2_inprocess.dll] Setting dll directory to C:\Windows\SysWOW64\inetsrv
[aspnetcorev2_inprocess.dll] Setting current directory to C:\inetpub\wwwroot\FaxApi\
[aspnetcorev2_inprocess.dll] Managed application exited with code 0
[aspnetcorev2_inprocess.dll] Starting shutdown sequence 1
[aspnetcorev2_inprocess.dll] Clr thread wait ended: clrThreadExited: 1
[aspnetcorev2_inprocess.dll] Event Log: 'Application '/LM/W3SVC/1/ROOT/FaxApi' with physical root 'C:\inetpub\wwwroot\FaxApi\' has exited from Program.Main with exit code = '0'. Please check the stderr logs for more information.'
End Event Log Message.
[aspnetcorev2_inprocess.dll] Canceling standard stream pipe reader
[aspnetcorev2_inprocess.dll] Stopping in-process worker thread
[aspnetcorev2_inprocess.dll] Stopping CLR
[aspnetcorev2_inprocess.dll] Event Log: 'Application '/LM/W3SVC/1/ROOT/FaxApi' with physical root 'C:\inetpub\wwwroot\FaxApi\' failed to load coreclr. Exception message:
CLR worker thread exited prematurely'
End Event Log Message.
[aspnetcorev2_inprocess.dll] InvalidOperationException 'CLR worker thread exited prematurely' caught at D:\workspace\_work\1\s\src\Servers\IIS\AspNetCoreModuleV2\InProcessRequestHandler\inprocessapplication.cpp:432
[aspnetcorev2_inprocess.dll] Failed HRESULT returned: 0x8007023e at D:\workspace\_work\1\s\src\Servers\IIS\AspNetCoreModuleV2\InProcessRequestHandler\dllmain.cpp:131
[aspnetcorev2_inprocess.dll] Starting app_offline monitoring in application 'C:\inetpub\wwwroot\FaxApi\'
[aspnetcorev2_inprocess.dll] Starting file watcher thread
Application is able to start if I recycle the pool or if I restart IIS. Crashing occurs only if the system restarts.
I am using hosting bundle 5.0.6.
OS Name: Microsoft Windows Server 2012 R2 Standard
Version: 6.3.9600 Build 9600
IIS pool configurations are in the following link:
IIS pool configuration

Hybris server is stuck when I restart it

I stop my server update when it was creating DDL statments and restart the server. Now my server is stuck at below line. I did ant clean all and again tried to start the server but still same issue.
How to resolve this?
log4j:WARN No such property [maxFileSize] in org.apache.log4j.DailyRollingFileAppender.
Feb 07, 2020 2:28:29 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/security/tags is already defined
log4j:WARN No appenders could be found for logger (de.hybris.platform.servicelayer.web.XSSFilter).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Feb 07, 2020 2:28:29 PM org.apache.catalina.startup.TldConfig execute
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Feb 07, 2020 2:28:30 PM org.apache.catalina.startup.TldConfig execute
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Run the following SQL request to check if the system is locked.
select process,locked from systeminit ;
if locked = 1, update it to 0.

Configure Security Manager on Tomcat7

Trying to configure Security Manager for Tomcat 7. We are running Java 1.8.0_51 on a 64 bit Windows 2008 server and run Tomcat as a service. I've added the following lines as Java Options:
-Djava.security.manager
-Djava.security.policy=D:\Program Files\Apache Software Foundation\Tomcat7.0\conf\catalina.policy
The security policy file is the default file and has not been modified. After adding the lines I can no longer start Tomcat. I get the following error messages:
2015-10-07 08:58:31 Commons Daemon procrun stderr initialized properties: reading security properties file: C:\Program Files\Java\jre1.8.0_51\lib\security\java.security jar: beginEntry META-INF/MANIFEST.MF jar: done with meta! jar: nothing to verify! scl: getPermissions ProtectionDomain (file:/D:/Program%20Files/Apache%20Software%20Foundation/Tomcat7.0/bin/tomcat-juli.jar <no signer certificates>) sun.misc.Launcher$AppClassLoader#c387f44 <no principals> java.security.Permissions#28d93b30 ( ("java.lang.RuntimePermission" "exitVM") ("java.io.FilePermission" "\D:\Program Files\Apache Software Foundation\Tomcat7.0\bin\tomcat-juli.jar" "read") ) scl: policy: reading file:/D:/Program%20Files/Apache%20Software%20Foundation/Tomcat7.0/conf/catalina.policy [Policy Parser]: sun.security.util.PropertyExpander$ExpandException: unable to expand property catalina.home [Policy Parser]: sun.security.util.PropertyExpander$ExpandException: unable to expand property catalina.base
I also see errors like the following:
java.lang.IllegalArgumentException: null KeyStore name
If I remove the new config lines all is well.
Any ideas?

Unasked Mojarra initializing

I'm using Tapestry 5.3 framework in my Java 1.7 web-app, and run in under Tomcat 7.x.
Suddenly today I've found in startup logs of my app these lines:
jul 31, 2014 12:12:46 PM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra 2.2.7 ( 20140610-1547 https://svn.java.net/svn/mojarra~svn/tags/2.2.7#13362) for context '/XXX'
jul 31, 2014 12:12:46 PM com.sun.faces.spi.InjectionProviderFactory createInstance
INFO: JSF1048: PostConstruct/PreDestroy annotations present. ManagedBeans methods marked with these annotations will have said annotations processed.
I have never seen these log-lines before in my app. Furthermore, "Initializing Mojarra" process takes some appreciable time.
So I should think, that somebody among our project developers have added special libraries - but there aren't any JSF or Faces libraries in the build.
I have no ideas what have changed and how I can cut out Mojarra from my project? Any help would be appreciated.
The problem was in jsf-*.jar libraries placed mistakenly in /lib folder of Tomcat. They were initialized due to tomcat startup. Removing them solved the problem.

Unable to start titan server with embedded cassandra and rexter

I am trying to run Titan with embedded cassandra and rexster. Downloaded Titan distribution titan-all-0.3.2 and unpacked on a linux box. After unpacking this is what i ran the command
$ ./bin/titan.sh config/titan-server-rexster.xml config/titan-server-cassandra.properties
This is what i see in the logs
After starting RexPro services its unable to deploy and start grizzly. Has anyone had this issue?
Exception stack trace:
13/10/18 14:51:31 INFO server.RexProRexsterServer: RexPro serving on port: [8184]
Oct 18, 2013 2:51:31 PM org.glassfish.grizzly.servlet.WebappContext deploy
INFO: Starting application [jersey] ...
Oct 18, 2013 2:51:31 PM org.glassfish.grizzly.servlet.WebappContext deploy
SEVERE: [jersey] Exception deploying application. See stack trace for details.
java.lang.RuntimeException: com.sun.jersey.api.container.ContainerException: No WebApplication provider is present
at org.glassfish.grizzly.servlet.WebappContext.initServlets(WebappContext.java:1479)
at org.glassfish.grizzly.servlet.WebappContext.deploy(WebappContext.java:265)
There were some packaging problems in some of the 0.3.2 zip files. You basically need to replace a jar file or two around Jersey to get it to work (or I think use the titan-cassandra distribution instead of titan-all).
You can read more about the issue here and its solution (also reported here), but the answer is:
You should be able to patch 0.3.2 by replacing this jar file in the
Titan lib directory:
jersey-core-1.8.jar
with:
jersey-core-1.17
(http://repo1.maven.org/maven2/com/sun/jersey/jersey-core/1.17/jersey-core-1.17.jar)

Resources