2

I am traying to get log4j to log to file in XMLLayout using the groovy log4j dsl. However, it seems that the "layout:"-part is being ignored. This is my setup:

appenders {
    file name: 'fileAppender', layout: xml, file: '/tmp/logs/applog.xml', threshold: org.apache.log4j.Level.INFO
    console name: "stdout", threshold: org.apache.log4j.Level.INFO
}

root {
    debug 'stdout', 'fileAppender'
}

So to stdout I corectly get my info-level pattern layout, but in the file I also get pattern-layout...

What's the trick here?

mtk
  • 13,221
  • 16
  • 72
  • 112
Julian
  • 994
  • 1
  • 9
  • 19

2 Answers2

1

This is a bug. I've fixed it for 2.0.1: http://jira.grails.org/browse/GRAILS-8635

The workaround as you found is to use the constructor explicitly instead of the DSL shortcut.

Burt Beckwith
  • 75,342
  • 5
  • 143
  • 156
0

Well I found out that you can just use layout: new XMLLayout() or layout: new HTMLLayout()

But still, in the documentation it says

By default the Log4j DSL assumes that you want to use a PatternLayout. However, there are other layouts available including:

xml - Create an XML log file
html - Creates an HTML log file
simple - A simple textual log
pattern - A Pattern layout

It seems to me that the shortcuts for xml and html don't work.

Julian
  • 994
  • 1
  • 9
  • 19