Trouble enabling Logging/Debugging for Orbeon Development - orbeon

After following the instructions on the following pages:
http://wiki.orbeon.com/forms/doc/developer-guide/xforms-logging
http://wiki.orbeon.com/forms/doc/developer-guide/configuration-properties
I have generated my log4j.xml and properties-local.xml files according the the instructions on the pages above and inserted them into the $TOMCAT_HOME/webapps/orbeon/WEB-INF/resources/config directory.
After restarting tomcat and building a few forms with the builder, I have been unable to locate any log information. There is no orbeon.log file on my system and no orbeon information in my tomcat log files either. Additionally I have run tomcat in debug mode to use remote debugging in IntelliJ and receive no output to the console.
I'm building the webapp myself using IntelliJ with the latest on https://github.com/orbeon/orbeon-forms/tree/4.0.0.m10-ce
currently commit 51f0e8f1b396336c612c16655e39abe6b807214b
I'm using Ubuntu 12.04 and running orbeon in Tomcat6.
I'm very new to orbeon development so I'm hoping the problem is something simple.
Any help would be greatly appreciated. Thanks.
Update:
I tried setting up the logger for an absolute path with no results, here is my current configuration (except with actual absolute paths).
log4j.xml
<!-- This is the standard log appender to the console (System.out) -->
<appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<param name="Encoding" value="UTF-8"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} %-5p %c{1} %x - %m%n"/>
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="debug"/>
</filter>
</appender>
<!-- Logging to a single file, typically used in development when you don't want
to be dealing with multiple files generated by the RollingFileAppender.
See: http://logging.apache.org/log4j/docs/api/org/apache/log4j/FileAppender.html -->
<appender name="SingleFileAppender" class="org.apache.log4j.FileAppender">
<param name="File" value="/Absolute_Path_To_$TOMCAT_HOME/logs/orbeon.log"/>
<param name="Append" value="false" />
<param name="Encoding" value="UTF-8"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} %-5p %c{1} %x - %m%n"/>
</layout>
</appender>
<!-- Logging to a rolling files. Every time the file exceeds a certain size, a backup
is created and the file used for logging is truncated.
See: http://logging.apache.org/log4j/docs/api/org/apache/log4j/RollingFileAppender.html -->
<appender name="RollingFileAppender" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="../logs/orbeon.log"/>
<param name="MaxFileSize" value="5MB"/>
<param name="maxBackupIndex" value="200"/>
<param name="Append" value="false" />
<param name="Encoding" value="UTF-8"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} %-5p %c{1} %x - %m%n"/>
</layout>
</appender>
<!-- XForms engine activity, see http://wiki.orbeon.com/forms/doc/developer-guide/xforms-logging -->
<category name="org.orbeon.oxf.xforms.processor.XFormsServer">
<priority value="debug"/>
</category>
<!-- To enable logging for any of the sub-systems below, copy that section outside of the comment block -->
<category name="org.orbeon.oxf.properties.Properties">
<priority value="debug"/>
</category>
<category name="org.orbeon.oxf.processor.pipeline.TeeProcessor">
<priority value="debug"/>
</category>
<category name="org.orbeon.oxf.processor.pipeline.choose.ConcreteChooseProcessor">
<priority value="debug"/>
</category>
<category name="org.orbeon.oxf.processor.generator.URLGenerator">
<priority value="debug"/>
</category>
<category name="org.orbeon.oxf.processor.xmldb.XMLDBProcessor">
<priority value="debug"/>
</category>
<category name="org.orbeon.oxf.processor.sql.SQLProcessor">
<priority value="debug"/>
</category>
<category name="org.orbeon.oxf.processor.PageFlowControllerProcessor">
<priority value="debug"/>
</category>
<category name="org.orbeon.oxf.processor.generator.RequestGenerator">
<priority value="debug"/>
</category>
<category name="org.orbeon.oxf.webapp.OPSSessionListener">
<priority value="info"/>
</category>
<category name="org.orbeon.oxf.webapp.OPSServletContextListener">
<priority value="info"/>
</category>
<!---->
<!-- Prevent extra display of eXist paging activity -->
<category name="org.exist.storage.btree.Paged">
<priority value="warn"/>
</category>
<category name="org.exist.storage.DBBroker">
<priority value="warn"/>
</category>
<category name="org.exist.storage.BrokerPool">
<priority value="warn"/>
</category>
<!-- You decide here which one of the loggers listed above you want to use. -->
<root>
<priority value="info"/>
<!--<appender-ref ref="ConsoleAppender"/>-->
<!--<appender-ref ref="ChainsawAppender"/>-->
<appender-ref ref="SingleFileAppender"/>
<!--<appender-ref ref="RollingFileAppender"/>-->
</root>
properties-local.xml
<properties xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:oxf="http://www.orbeon.com/oxf/processors">
<property as="xs:NMTOKENS" name="oxf.xforms.logging.debug"
value="document model submission control event action analysis server server-body html submission-details submission-body"/>
</properties>
Update2
Following some of the suggestions, I've ensured that write permissions is not the issue. I've also tried using the ConsoleAppender and still got no output, but the webapp also crashed after a few minutes and I found this exception in the tomcat log files.
WARNING: Cannot serialize session attribute orbeon.resources.dynamic.cb088a8a347ad72a00012a9d8569b5e9c5dd6381 for session 29AE194AA69E0D51C111F5035C219E7B
java.io.NotSerializableException: scala.collection.JavaConversions$MapWrapper
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1585)
at org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:1015)
at org.apache.catalina.session.StandardManager.doUnload(StandardManager.java:528)
at org.apache.catalina.session.StandardManager.unload(StandardManager.java:469)
at org.apache.catalina.session.StandardManager.stop(StandardManager.java:678)
at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4882)
at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:936)
at org.apache.catalina.startup.HostConfig.undeployApps(HostConfig.java:1359)
at org.apache.catalina.startup.HostConfig.stop(HostConfig.java:1330)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:326)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1098)
at org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1110)
at org.apache.catalina.core.StandardEngine.stop(StandardEngine.java:468)
at org.apache.catalina.core.StandardService.stop(StandardService.java:604)
at org.apache.catalina.core.StandardServer.stop(StandardServer.java:788)
at org.apache.catalina.startup.Catalina.stop(Catalina.java:662)
at org.apache.catalina.startup.Catalina$CatalinaShutdownHook.run(Catalina.java:706)

The logs folder should be available inside Tomcat folder if you declare log4j as below
<appender name="SingleFileAppender" class="org.apache.log4j.FileAppender">
<param name="File" value="../logs/orbeon.log"/>
<param name="Append" value="false" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} %-5p %c{1} %x - %m%n"/>
</layout>
</appender>
and
<!-- You decide here which one of the loggers listed above you want to use. -->
<root>
<priority value="debug"/>
<!--<appender-ref ref="ConsoleAppender"/>-->
<!--<appender-ref ref="ChainsawAppender"/>-->
<appender-ref ref="SingleFileAppender"/>
<!--<appender-ref ref="RollingFileAppender"/>-->
</root>
If you have simply placed the Orbeon war file in webapps folder, then i suggest to remove the .war file once the server is started. After server start, tomcat unpacks the war and creates a folder. If .war is not removed everytime you restart the tomcat server, it will unpack and overwrites in the same folder again.

With the default log4j.xml, the SingleFileAppender is being used, and the file it writes to is referenced using a relative path:
<param name="File" value="../logs/orbeon.log"/>
So the location of the file on disk will depend on the directory from which you start Tomcat. It is not uncommon to start Tomcat from its bin directory, in which case the log file will end up in Tomcat's logs directory. But if you're starting Tomcat from a different location, or would like the log file to end up in the different directory, you can edit your log4j.xml and put there an absolute path to the orbeon.log.

Related

ERROR StatusLogger No logging configuration

I am using log4j2
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.5</version>
</dependency>
and a very basic configuration xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
</layout>
</appender>
<category name="org.apache.log4j.xml">
<priority value="info" />
</category>
<Root>
<priority value ="debug" />
<appender-ref ref="STDOUT" />
</Root>
</log4j:configuration>
For some reason logging is not working. I am getting
ERROR StatusLogger Error parsing /home/sfalk/workspace/java/lazy-model-access/lamoa-parent/lamoa-server/target/classes/log4j2.xml
ERROR StatusLogger No logging configuration
What am I doing wrong here?
Your configuration file is for log4j 1.x, not 2.5

Where is the log file in log4net?

I've got the following entries in my Web.config file in an asp.net mvc application:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
...
</configSections>
<log4net>
<appender name="PublicAccessAppender" type="log4net.Appender.RollingFileAppender">
<datePattern value="'C:\Users\my_user_name\Documents\Temp\logs\public-access.'yyyy-MM-dd'.log'" />
<staticLogFileName value="false" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<maxSizeRollBackups value="5" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="PublicAccessAppender" />
</root>
</log4net>
...
</configuration>
I hope it's pretty self-explanatory what I'm trying to achieve, but when I run the application (hosted in IIS), I get no log file. FWIW, the directory hierarchy exists up to Temp folder, and I'd like log4net to generate the rest of the directories/files in the path.
I've added the log4net nuget package to my application, and I'm logging with the INFO level.
What am I missing here?
I think you can't put full path into datePattern, there must be just YYYYmmdd and things like that. Put the file path into file element:
<file value="C:\Users\my_user_name\Documents\Temp\logs\public-access.log" />
<datePattern value="yyyyMMdd" />
<preserveLogFileNameExtension value="true" />
The last element forces to put datePattern before the .log extension which was probably your original goal..
Here's the working appender configuration:
<appender name="PublicAccessAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\temp\my_user_name\Documents\Temp\logs\app.log" />
<datePattern value=".yyyy-MM-dd" /><!-- can be omitted as it's the default datePattern value -->
<rollingStyle value="Date" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
Note to readers struggling with log4net configuration: asp.net hosted in IIS pretty much has 0 write permssions, so the issue you're most likely struggling with is that your web app simply doesn't have permission to write to the log file.
That's what was happening for me, and I noticed it by inspecting the contents of log4net.LogManager.GetRepository().ConfigurationMessages in the debugger after calling .Configure().
I followed this post to give my web app the necessary persmissions to write to the log file (namely Read/Write/Modify).

How to enable Common.Logging.Log4Net

I am trying to enable Common.Logging.Log4Net to write all types of logs to a log file. The tutorials make it look so simple but I don't know what I am doing wrong. These are the steps I am taking:
Create a new ASP.NET MVC empty project
Install the "Common Logging Log4Net 1211" NuGet package
Add the following lines to the default web.config:
<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
</common>
<log4net>
<root>
<level value="ALL" />
<appender-ref ref="FileAppender" />
</root>
<appender name="FileAppender" type="log4net.Appender.FileAppender" >
<param name="File" value="C:\Users\MyName\Downloads\log.txt" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %level %logger - %message%newline" />
</layout>
</appender>
</log4net>
Make sure the app. pool identity account has RW access to the path where I am trying to save the log file.
Throw a random exception from code for testing purposes.
Am I missing anything? Is there a way I can debug log4net? Please help this poor soul. Thank you.
The issue was related to the NuGet package for "Common.Logging.Log4Net" changing the name of the assembly. This actually fixed it (plesae note the new assembly name, being Common.Logging.Log4Net1211):
<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net1211">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
</common>
https://stackoverflow.com/a/756241/3469201
<configuration>
<appSettings>
<add key="log4net.Internal.Debug" value="true"/>
</appSettings>
</configuration>
Then, to determine the file in which you want to save the output you can add the following code in the same .config file:
<configuration>
...
<system.diagnostics>
<trace autoflush="true">
<listeners>
<add
name="textWriterTraceListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="C:\tmp\log4net.txt" />
</listeners>
</trace>
</system.diagnostics>
...
</configuration>
I'm not familiar with Common.Logging.Log4Net. Here is the simple log4net steps that I use -
Install log4net from NuGet.
Insert the following settings in web.config (you can configure the way you want)
Then log.
If you want to use IoC container, you can read my question I asked last month.
web.config
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<log4net>
<root>
<level value="DEBUG"/>
<appender-ref ref="FileAppender"/>
</root>
<appender name="FileAppender" type="log4net.Appender.FileAppender">
<file value="log-file.txt" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
</log4net>
</configuration>
Testing inside Global.asax.cs
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RouteConfig.RegisterRoutes(RouteTable.Routes);
XmlConfigurator.Configure();
// You can inject it to your code using IoC container.
var logger = LogManager.GetLogger(typeof(MvcApplication));
logger.Debug("Test Debug.");
logger.Error("Test Error.");
logger.Fatal("Test Fatal.");
logger.Info("Test Info.");
}
}
Result
2015-06-04 11:48:05,885 [1] DEBUG DemoLog4Net.MvcApplication [(null)] - Test Debug.
2015-06-04 11:48:05,921 [1] ERROR DemoLog4Net.MvcApplication [(null)] - Test Error.
2015-06-04 11:48:05,922 [1] FATAL DemoLog4Net.MvcApplication [(null)] - Test Fatal.
2015-06-04 11:48:05,922 [1] INFO DemoLog4Net.MvcApplication [(null)] - Test Info.

netbeans glassfish hibernate log4j2

I have a simple Netbeans 7.1.2 (NON MAVEN) project that use glassfish 3.1 server for testing.
I created a log4j2.xml file and placed it on the classpath
here it is
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Threshold" value="debug"/>
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} [%t] %-5p %c{1} - %m%n"/>
</layout>
</appender>
<appender name="rolling-file" class="org.apache.log4j.RollingFileAppender">
<param name="file" value="c:\tmp\Program-Name.log"/>
<param name="MaxFileSize" value="500KB"/>
<param name="MaxBackupIndex" value="4"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %l - %m%n"/>
</layout>
</appender>
<logger name="org.hibernate">
<level value="info" />
</logger>
<root>
<priority value ="debug" />
<appender-ref ref="console" />
<appender-ref ref="rolling-file" />
</root>
</log4j:configuration>
the project uses hibernate to store data from a web service to a database.
However I am not able to log anything. I can see the logs of hibernate into the Netbeans IDE but I cannot see the created on the filesystem file.
I have this error when calling the web service
SEVERE: ERROR StatusLogger Unknown object "logger" of type org.apache.logging.log4j.core.config.LoggerConfig is ignored
SEVERE: ERROR StatusLogger root contains an invalid element or attribute "priority"
SEVERE: ERROR StatusLogger Unknown object "root" of type org.apache.logging.log4j.core.config.LoggerConfig is ignored
could someone pls help or give some advice I googled and stackoverflowed but without chance.
Paolo
I think that your log4j2.xml file is mixed with the old log4j style xml.
I'm having the same trouble as you when it comes to appending hibernate log to my application's log file. But I think that I can help with the logger error.
Try this file instead (and note the changes that I made):
<?xml version="1.0" encoding="UTF-8" ?>
<configuration name="SOME_PROJ_NAME" status="OFF">
<appenders>
<RollingFile name="rolling-file" fileName="c:/tmp/Program-Name.log" filePattern="c:/tmp/$${date:yyyy-MM}/Program-Name-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout>
<pattern>%d{ABSOLUTE} [%t] %-5p %c{1} - %m%n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="6" modulate="true"/>
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
</RollingFile>
</appenders>
<loggers>
<root level="info"
<appender-ref ref="rolling-file"/>
</root>
<logger name="org.hibernate level="info">
<appender-ref ref="rolling-file"/>
</logger>
</loggers>
</configuration>
It is quite similar to the one that I'm using. Note that this file should be on classpath for log4j2 auto configuration to kick in.
The most important thing you should do when using the net to configure log4j2 is that you're looking at log4j2 and not log4j style configuration.
I suggest that you look in http://logging.apache.org/log4j/2.x/ for further info. They have a good downloadable pdf that you can check out.
In addition, check out my question about a similar problem.

Getting exception with struts2?

I tried to run simple example(Hello wold) in struts-2.3.4.1 with tomcat server 7.0.
But when i run this sample application i got following exception :
java.lang.NullPointerException
org.apache.struts2.impl.StrutsActionProxy.getErrorMessage(StrutsActionProxy.java:69)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:501)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:432)
used Log4j.xml Configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<appender class="org.apache.log4j.rolling.RollingFileAppender" name="FixedWindowRollingFile">
<param name="Append" value="true"/>
<param name="ImmediateFlush" value="true"/>
<rollingPolicy class="org.apache.log4j.rolling.FixedWindowRollingPolicy">
<param name="fileNamePattern" value="c:/logs/HelloExample/HelloExample.%i.log"/>
<param name="minIndex" value="1"/>
<param name="maxIndex" value="10"/>
</rollingPolicy>
<triggeringPolicy class="org.apache.log4j.rolling.SizeBasedTriggeringPolicy">
<param name="MaxFileSize" value="1002400"/>
</triggeringPolicy>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %p %c{1}:%L - %m%n"/>
</layout>
</appender>
<appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.SimpleLayout"/>
</appender>
<root>
<priority value="DEBUG"/>
<appender-ref ref="ConsoleAppender"/>
<appender-ref ref="FixedWindowRollingFile"/>
</root>
</log4j:configuration>
Also I have used my own log4j.xml configuration file to configure web application but i got this exception regularly(generated log file https://gist.github.com/3851738).

Resources