Logback erzeugt keine Lockdateien

Andyx1975

Mitglied
Hallo,

ich bin gerade dabei für meine webapp logging einzuführen...hierzu habe ich mir logback ausgesucht. Ich bekomme jedoch keinen Logfile in meinem WAR Verzeichnis hinterlegt. Ich bin wie folgt vorgegangen:

1. Unter web-inf/lib habe ich "slf4j-api-1.6.4.jar" + "logback-classic-1.0.1.jar + "logback-core-1.0.1.jar" hinterlegt und zum Build-Path hinzugefügt

2. Ich habe unter web-inf/classes eine XML Namens "logback.xml" hinterlegt
Code:
<?xml version="1.0" encoding="UTF-8"?>
<configuration> 
    <contextName>webAdmin</contextName>
    <jmxConfigurator contextName="webAdmin" />    
    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
        <File>logs/logfile.log</File>
        <Append>false</Append>
        <BufferedIO>false</BufferedIO>
        <ImmediateFlush>true</ImmediateFlush>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <Pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</Pattern>
        </layout>
    </appender>
    <root>
        <level value="DEBUG" />
        <appender-ref ref="FILE" />
    </root>
    <logger>
        <level value="DEBUG" />
    </logger>
</configuration>

3. Den logger rufe ich wie folgt auf:
Code:
static final Logger logger = LoggerFactory.getLogger(CSendEmail.class);
logger.debug ("Test");

4. Auf der Konsole wird mir dann folgendes angezeigt:
Code:
09:10:54,531 |-INFO in ch.qos.logback.classic.LoggerContext[webAdmin] - Could NOT find resource [logback.groovy]
09:10:54,532 |-INFO in ch.qos.logback.classic.LoggerContext[webAdmin] - Could NOT find resource [logback-test.xml]
09:10:54,532 |-INFO in ch.qos.logback.classic.LoggerContext[webAdmin] - Found resource [logback.xml] at [file:/C:/Users/wernera/Documents/workspace/webAdministrator/war/WEB-INF/classes/logback.xml]
09:10:54,603 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
09:10:54,624 |-INFO in ch.qos.logback.classic.joran.action.ContextNameAction - Setting logger context name as [webAdmin]
09:10:54,624 |-INFO in ch.qos.logback.classic.joran.action.JMXConfiguratorAction - begin
09:10:54,664 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender]
09:10:54,668 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE]
09:10:54,685 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@8:21 - no applicable action for [BufferedIO], current pattern is [[configuration][appender][BufferedIO]]
09:10:54,685 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@9:25 - no applicable action for [ImmediateFlush], current pattern is [[configuration][appender][ImmediateFlush]]
09:10:54,727 |-WARN in ch.qos.logback.core.FileAppender[FILE] - This appender no longer admits a layout as a sub-component, set an encoder instead.
09:10:54,727 |-WARN in ch.qos.logback.core.FileAppender[FILE] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
09:10:54,727 |-WARN in ch.qos.logback.core.FileAppender[FILE] - See also Logback Error Codes for details
09:10:54,728 |-INFO in ch.qos.logback.core.FileAppender[FILE] - File property is set to [logs/logfile.log]
09:10:54,740 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - ROOT level set to DEBUG
09:10:54,740 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE] to Logger[ROOT]
09:10:54,741 |-ERROR in ch.qos.logback.classic.joran.action.LoggerAction - No 'name' attribute in element logger, around line: 18, column: 13
09:10:54,741 |-ERROR in ch.qos.logback.classic.joran.action.LevelAction - For element <level>, could not find a logger at the top of execution stack.
09:10:54,741 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
09:10:54,743 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@12d27699 - Registering current configuration as safe fallback point

In meinem War-Verzeichnis wird mir jedoch kein Logfile im Ordner logs angezeigt, obwohl ich "<File>logs/logfile.log</File>" angegeben habe. Weiss jemand eine Lösung?

Danke
Andy
 
Ok....ich habe mittlerweile herausgefunden, dass doch eine logdatei angelegt wird. Jedoch nicht im WAR Verzeichnis, sondern eine Ebene darüber. Wenn ich die xml auf "<File>war/logs/logfile.log</File>" ändere, landet die Datei im richtigen Ordner. Gibt es hier eine möglichkeit das war gegen eine Dynamische Variable auszutauschen, weil wenn ich den WAR Ordner umbenenne, möchte ich nicht jedesmal die XML ändern.
 
Zurück