We have a log4j file that has the following pattern:
#|%d{yyyy-MM-dd HH:mm:ss.SSS}|%X{Machine}|%X{CorrelationId}|%X{Sender}|%X{Receiver}|%-5p|%X{Runtime}|%X{ClientUser}|%c|%M|%L|%m%n
I created a LogFilePatternReceiver with the following pattern:
#|TIMESTAMP|PROP(MACHINE)|PROP(CORRELATIONID)|PROP(SENDER)|PROP(RECEIVER)|LEVEL|PROP(RUNTIME)|PROP(CLIENTUSER)|CLASS|METHOD|LINE|MESSAGE
But when I start that receiver I get an error:
java.lang.IllegalArgumentException: invalid expression:
at org.apache.log4j.rule.ExpressionRule$PostFixExpressionCompiler.compileExpression(ExpressionRule.java:132)
at org.apache.log4j.rule.ExpressionRule.getRule(ExpressionRule.java:64)
at org.apache.log4j.rule.ExpressionRule.getRule(ExpressionRule.java:56)
at org.apache.log4j.varia.LogFilePatternReceiver.initialize(LogFilePatternReceiver.java:557)
at org.apache.log4j.varia.LogFilePatternReceiver$1.run(LogFilePatternReceiver.java:801)
at java.lang.Thread.run(Unknown Source)
regexp is #|(\w+-\w+-\w+ \w+:\w+:\w+.\w+)|(.+?)|(.+?)|(.+?)|(.+?)|(.+?)|(.+?)|(.+?)|(.+?)|(.+?)|(.+?)|(.+)
I don't really see where the error is? Any input? Can I use the "PROP(...)" keyword like that for columns that are non-standard?
Yes, you can use the PROP keyword for your own columns..
Can you try the latest developer snapshot of Chainsaw? It can parse your log4j.xml or log4j.properties configuration containing FileAppender entries and will build a matching Chainsaw config to process that.
Snapshot available here..the new version also has a lot of new features:
http://people.apache.org/~sdeboy
What usually trips people up is timestamp formatting and special characters, but I don't see anything weird here, so see if the latest developer snapshot helps.
Scott
Related
How can I change the name of log4j.properties and the location of this as well?
You can change its location like so:
java -Dlog4j.configuration=file:/path_to_file_here/log4j.properties YourApplication
You should also read the manual.
Regarding changing the name, this is how you can achieve this:
First, you must add the following line to your java runtime command:
-Dlog4j.configuration=test.properties
For example lets assume you are using log4j in your web application deployed on Tomcat.
Add the above mentioned line in the java runtime command to start up Tomcat:
C:\Tools\java\j2sdk1.4.2_01\bin\java.exe -jar
-Duser.dir="C:\Tools\Tomcat 4.1"
-Dlog4j.configuration=test.properties
-Djava.endorsed.dirs="C:\Tools\Tomcat 4.1\common\endorsed"
"C:\Tools\Tomcat 4.1\bin\bootstrap.jar" start
You will also possibly want to read this.
I know this is a really old post, but the first thread when I searched for the question. And my found solution is:
System.setProperty("log4j.configurationFile", "theNameIWant.properties");
I am trying to generate a C# class from the following ReqIF XSD file.
I have tried with xsd.exe which failed and now also with xsd2code which fails with the following error message (translation: reference to undeclared attribute group):
Xsd2Code Version 3.4.0.32990
Code generation utility from XML schema files.
Error: Verweis auf nicht deklarierte Attributgruppe http://www.w3.org/1999/xhtml:xhtml.style.attrib.
SubType: Unspecified
Rule:
I suppose the xsd file is not 100% correct. I tried to get some information about the xsd format, but with my limited knowledge I was not able to solve the issue.
Does somebody have an idea what could be wrong here or how I could proceed?
Thanks!
I was able to generate java code with the linked files and the following command line on Windows (make sure the files are all in the same directory to make your life easier):
NOTE: It took my PC about 15 minutes to get past the parsing stage. I had thought it was locked up, but grabbed some coffee and was pleasantly surprised when I returned.
"<path_to_xjc.exe>" "<path_to_reqif.xsd>" -b "<path_to_linked_xjb_file>" -extension -p <the.package.name.you.want.to.generate.to>
Link to files I used to generate
I'm using CAS for single signon solution, My log(log4j version 1.2.15) file completely fills with the Exception(org.jasig.cas.authentication.handler.BadCredentialsAuthenticationException)
Stack trace when User enters invalid login credentials.
Is there a solution to trim the Stack trace in CAS or Java?
I can't use log4j EnhancePatternLayout to achieve this as it requires log4j version 1.2.16
Any suggestions around this problem would be appreciated.
Thanks
I haven't used CAS. However, the way that I've gotten around similar problems in the past is by suppressing log messages from the offending class. For example, if you're using a log4j.properties file, insert this line:
log4j.logger.com.jasig.cas.WhateverClassLogsTheException=OFF
Note that you will need to suppress messages from the class that throws the exception, not the exception class itself. Also, you can also use FATAL or other values to ensure that only log messages that are at or above the given level are logged. See the Log4J docs for more information.
Note that this will suppress all messages from that class, not just the particular log message that produces that exception.
The problem is CAS is passing Exception object to Log4j,so I did comment that line in my overlayed class. BindLdapAuthenticationHandler.java
I am trying to track down a problem with GWT. I get an error which I want to track down to the source but log4j truncates the stacktrace by indicating something like "... 26 more" hence I cannot determine the exact location for the problem. I tried finding out if there is anyway to prevent that truncation but have been unable to find any option that will accomplish that. Is this truncation a configurable feature?
I am running Tomcat 6.0.31, Spring 3.0 (for backend), GWT 2.1.0.
Thanks
It isn't log4j truncating the stack trace, it's standard Java. And it's actually only making the trace more readable because those lines that were omitted were already output by the 'enclosing' exception. See Throwable javadoc.
When I launch CruiseControl.NET with a particular configuration file I receive the following error:
ThoughtWorks.CruiseControl.Core.Config.ConfigurationException: Duplicate node detected
What does this mean, and what causes it?
I think you have 2 nodes in your config where it only expected one. Is there any chance you could post the config file it is throwing the exception on here as additional information? I'm using cruisecontrol (not the .net version) currently and find it can be very picky about it's XML files (rightly so) but not tell you anything about where in the file the exceptions were thrown from.
I found that I had an incorrectly structured config file. In particular, some blocks were outside of the configuration section. The error pointed to the second of these exec sections- apparently it didn't like that there was more than one of a given section inside the project.
Thus, the error occurred due a config file like this:
<project>
<tasks>
...
</tasks>
<exec>...</exec>
<exec>...</exec>
<project>
In my case I had something like:
<task>...</task>
<sourceControls>...</sourceControls>
<task>...</task>
<publishers>...</publishers>
It didn't like the two "<task>" nodes so I fixed it by removing the first "<task>" node. I was trying to do some stuff before getting the latest from svn, and then doing the build after that in the second "<task>" node. I'll need to revisit how to do that...any suggestions?