[logback-user] Extending Logback Spring extension to allow <appender/> tags in Spring XML

yihtserns sim_yihtsern at yahoo.com
Wed Dec 2 14:52:25 UTC 2015


Hi.

(Not sure if this is the correct place to post this, but... oh well.)
So, I was checking out Logback Spring extension[1], and reached the part
about declaring appender as bean in Spring XML[2].   I then thought, "hmm,
maybe I can do something about this!" so I made a project[3] to allow
declaring <appender /> tags in Spring XML.

So instead of this:
```
<beans ...>
    ...
    <bean id="consoleAppender" class="ch.qos.logback.core.ConsoleAppender"
init-method="start" destroy-method="stop">
        <property name="context" value="#{
T(org.slf4j.LoggerFactory).getILoggerFactory() }"/>
        <property name="encoder">
            <bean
class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"
init-method="start" destroy-method="stop">
                <property name="context" value="#{
T(org.slf4j.LoggerFactory).getILoggerFactory() }"/>
                <property name="pattern" value="%date %-5level [%thread]
%logger{36} %m%n"/>
            </bean>
        </property>
    </bean>
    ...
</beans>
```

you can do this:
```
<beans ... xsi:schemaLocation="... http://logback.qos.ch
logback-lenient.xsd">
    ...
    <appender name="consoleAppender"
class"ch.qos.logback.core.ConsoleAppender" xmlns="http://logback.qos.ch">
        <encoder
class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%date %-5level [%thread] %logger{36} %m%n"</pattern>
        </encoder>
    </appender>
    ...
</beans>
```

To try it out, go to https://github.com/yihtserns/logback-spring-config. 
Hope you'll like it.  :)

[1] https://github.com/qos-ch/logback-extensions/wiki/Spring
[2]
https://github.com/qos-ch/logback-extensions/wiki/Spring#using-applicationcontextxml
[3] https://github.com/yihtserns/logback-spring-config




--
View this message in context: http://logback.10977.n7.nabble.com/Extending-Logback-Spring-extension-to-allow-appender-tags-in-Spring-XML-tp14458.html
Sent from the Users mailing list archive at Nabble.com.


More information about the logback-user mailing list