wood burning stoves 2.0*
The moose likes Ant, Maven and Other Build Tools and the fly likes Appender Layout Problem- log4j:ERROR Unexpected char [u] at position Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Appender Layout Problem- log4j:ERROR Unexpected char [u] at position " Watch "Appender Layout Problem- log4j:ERROR Unexpected char [u] at position " New topic
Author

Appender Layout Problem- log4j:ERROR Unexpected char [u] at position

Mat Anthony
Ranch Hand

Joined: May 21, 2008
Posts: 232
Hi All,
I'm currently trying to programmatically create a DailyRollingFileAppender using the following method:-

private DailyRollingFileAppender createDailyRollingFileAppender(String appenderName, String file)
{
DailyRollingFileAppender appender = new DailyRollingFileAppender();
appender.requiresLayout();
appender.setName(appenderName);
appender.setFile(file);
appender.setDatePattern(log4jDatePatternFileExt);
Layout layout = new PatternLayout(log4jInternalFilePattern);
appender.setLayout(layout);
return appender;
}

The log4jInternalFilePattern contains the following:-
"%d{EEE MMM dd HH:mm:ss} BST %d{yyyy} [%u] %m%n"

Every time I call:-
Layout layout = new PatternLayout(log4jInternalFilePattern);

The following error appears in the console:-

log4j:ERROR Unexpected char [u] at position 39 in conversion patterrn.

Has anybody seen this before??
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Nope, what is %u supposed to be replaced by? Is it valid in that location?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Mat Anthony
Ranch Hand

Joined: May 21, 2008
Posts: 232
Hi Martijn,
That was a quick response, I just typed it in.

The %u is supposed to be replaced by the username of the person that has just logged in.

Richard

Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

I assume you've played around with removing the %u, removing the '[' and ']' characters?
Mat Anthony
Ranch Hand

Joined: May 21, 2008
Posts: 232
Hi Martijn,
just found out that we seem to be using a customized PatternLayout that overrides
the createPatternParser method, hence since I was using the default the error ocurred.

Richard


Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Glad you figured it out!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Appender Layout Problem- log4j:ERROR Unexpected char [u] at position
 
Similar Threads
DailyRollingFileAppender & Servlets with Tomcat
Unable to write footer log4j.DailyRollingFileAppender
log4j config file giving FileNotFoundException
Static object doesn't get collected. Why?
Does Struts have a log? Can't figure out why ActionServlet is not initializing