Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Log4j 2 #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 9 additions & 8 deletions README.md
Expand Up @@ -18,7 +18,7 @@ The extension needs a configuration file for the chosen logging system.
The file can be overridden by putting one into your *config* directory:

* Log4j (Default)
Default configuration file: 'config/trinidad-logging.properties'
Default configuration file: 'config/trinidad-logging.xml'
* Logback
Default configuration file: 'config/trinidad-logging.xml'
* java.util.logging
Expand All @@ -38,13 +38,14 @@ To enable the extension add it to your Trinidad configuration e.g. *trinidad.yml
Here's a (.properties) configuration example extracted from the Tomcat's doc:

```
log4j.rootLogger=INFO, R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=log/trinidad.log
log4j.appender.R.MaxFileSize=10MB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler

org.apache.juli.FileHandler.level = FINE
org.apache.juli.FileHandler.directory = ${catalina.base}/logs
org.apache.juli.FileHandler.prefix = servlet-examples.

java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
```

You can find further information on how to write your own extension in the wiki:
Expand Down
4 changes: 2 additions & 2 deletions lib/trinidad_logging_extension.rb
Expand Up @@ -7,14 +7,14 @@ class LoggingServerExtension < ServerExtension

def configure(tomcat)
@options[:logging_system] ||= 'log4j'
@options[:config] ||= @options[:logging_system].eql?('logback') ?
@options[:config] ||= (@options[:logging_system] =~ /logback|log4j/i) ?
'config/trinidad-logging.xml' : 'config/trinidad-logging.properties'

require_common_jars

case @options[:logging_system]
when 'log4j'
set_config_property 'log4j.configuration'
set_config_property 'log4j.configurationFile'
require_log4j_jars
configure_jul_bridge
when 'logback'
Expand Down
10 changes: 5 additions & 5 deletions lib/trinidad_logging_extension/jars.rb
Expand Up @@ -4,9 +4,8 @@ module Trinidad
module Extensions
module Logging
module Jars
SLF4J_VERSION = '1.6.1'
LOG4J_VERSION = '1.2.17'
LOG4J_EXTRAS_VERSION = '1.1'
SLF4J_VERSION = '1.7.12'
LOG4J_VERSION = '2.3'
LOGBACK_VERSION = '0.9.29'

def require_common_jars
Expand All @@ -17,9 +16,10 @@ def require_common_jars

def require_log4j_jars
require "slf4j-log4j12-#{SLF4J_VERSION}.jar"
require "log4j-#{LOG4J_VERSION}"
require "log4j-1.2-api-#{LOG4J_VERSION}.jar"
require "log4j-api-#{LOG4J_VERSION}.jar"
require "log4j-core-#{LOG4J_VERSION}.jar"
require "jul-to-slf4j-#{SLF4J_VERSION}.jar"
require "apache-log4j-extras-#{LOG4J_EXTRAS_VERSION}.jar"
end

def require_logback_jars
Expand Down
2 changes: 1 addition & 1 deletion lib/trinidad_logging_extension/version.rb
@@ -1,7 +1,7 @@
module Trinidad
module Extensions
module Logging
VERSION = '1.0.1'
VERSION = '1.1.0'
end
end
end
Binary file removed trinidad-libs/apache-log4j-extras-1.1.jar
Binary file not shown.
Binary file removed trinidad-libs/jcl-over-slf4j-1.6.1.jar
Binary file not shown.
Binary file added trinidad-libs/jcl-over-slf4j-1.7.12.jar
Binary file not shown.
Binary file removed trinidad-libs/jul-to-slf4j-1.6.1.jar
Binary file not shown.
Binary file added trinidad-libs/jul-to-slf4j-1.7.12.jar
Binary file not shown.
Binary file added trinidad-libs/log4j-1.2-api-2.3.jar
Binary file not shown.
Binary file removed trinidad-libs/log4j-1.2.17.jar
Binary file not shown.
Binary file added trinidad-libs/log4j-api-2.3.jar
Binary file not shown.
Binary file added trinidad-libs/log4j-core-2.3.jar
Binary file not shown.
Binary file removed trinidad-libs/slf4j-api-1.6.1.jar
Binary file not shown.
Binary file added trinidad-libs/slf4j-api-1.7.12.jar
Binary file not shown.
Binary file removed trinidad-libs/slf4j-jdk14-1.6.1.jar
Binary file not shown.
Binary file added trinidad-libs/slf4j-jdk14-1.7.12.jar
Binary file not shown.
Binary file removed trinidad-libs/slf4j-log4j12-1.6.1.jar
Binary file not shown.
Binary file added trinidad-libs/slf4j-log4j12-1.7.12.jar
Binary file not shown.