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

[WIP] Replace log4j with slf4j #977

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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ bin
ant.*
dist
.DS_Store
.idea
.flattened-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public WOComponent pingAction() {
ec.saveChanges();
result = pageWithName("ERXSuccess");
} catch (Exception e) {
log.error(e);
log.error(e.getMessage(), e);
} finally {
ERCoreBusinessLogic.setActor(null);
ec.unlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

import java.util.Timer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.webobjects.eocontrol.EOEditingContext;
import com.webobjects.foundation.NSArray;

Expand All @@ -18,13 +21,12 @@
import er.extensions.eof.ERXEC;
import er.extensions.foundation.ERXProperties;
import er.extensions.foundation.ERXUtilities;
import er.extensions.logging.ERXLogger;
import er.javamail.ERJavaMail;

public class Application extends ERXApplication {

/** logging support */
public static final ERXLogger log = ERXLogger.getERXLogger(Application.class);
public static final Logger log = LoggerFactory.getLogger(Application.class);

/**
* Main initialization function.
Expand Down
9 changes: 0 additions & 9 deletions Applications/JavaMonitor/Resources/Properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ WOAllowRapidTurnaround=false

WODeploymentBackups=true

log4j.rootCategory=INFO, A1

# A1 is set to be a FileAppender which outputs to System.out.
log4j.appender.A1=org.apache.log4j.ConsoleAppender

# A1 uses PatternLayout.
log4j.appender.A1.layout=er.extensions.logging.ERXPatternLayout
log4j.appender.A1.layout.ConversionPattern=%d %-5p %V{u/f} [%t] %C{2} (%F:%L) - %m%n

ERXRest.MHost.type.alias = osType

# Hide the Migrations tab.
Expand Down
14 changes: 14 additions & 0 deletions Applications/JavaMonitor/Resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%d %-5p %V{u/f} [%t] %C{2} (%F:%L) - %m%n" />
</Console>
</Appenders>
<Loggers>
<Logger name="org.apache.log4j.xml" level="info" />
<Root level="info">
<AppenderRef ref="STDOUT" />
</Root>
</Loggers>
</Configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the "Apple Software"), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.

The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.

IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.webobjects.appserver.WOApplication;
import com.webobjects.appserver.WOContext;
Expand All @@ -27,9 +28,9 @@
public class MonitorComponent extends ERXComponent {

public static final boolean isClickToOpenEnabled = Boolean.parseBoolean(System.getProperty("er.component.clickToOpen", "false"));
protected Logger log = Logger.getLogger(getClass());

protected Logger log = LoggerFactory.getLogger(getClass());

private static final long serialVersionUID = -1880897151494772932L;

public final int APP_PAGE = 0;
Expand All @@ -49,11 +50,11 @@ public class MonitorComponent extends ERXComponent {
public Application theApplication = (Application) WOApplication.application();

private WOTaskdHandler _handler;

private MApplication myApplication;
private MInstance myInstance;
private MHost myHost;

private String _message;

public MonitorComponent(WOContext aWocontext) {
Expand All @@ -66,7 +67,7 @@ public void awake() {
super.awake();
_message = null;
}

protected NSMutableArray allHosts() {
return siteConfig().hostArray();
}
Expand All @@ -78,7 +79,7 @@ protected MSiteConfig siteConfig() {
public Session mySession() {
return (Session) super.session();
}

public WOTaskdHandler handler() {
return _handler;
}
Expand All @@ -102,22 +103,22 @@ public void setMyInstance(MInstance instance) {
myInstance = instance;
myApplication = instance.application();
}

public final MHost myHost() {
return myHost;
}

public void setMyHost(MHost host) {
myHost = host;
}

public String message() {
if (_message == null) {
_message = ((Session)session()).message();
}
return _message;
}

/*
public void appendToResponse(WOResponse response, WOContext context) {
ERXClickToOpenSupport.preProcessResponse(response, context, isClickToOpenEnabled);
Expand Down
26 changes: 26 additions & 0 deletions Applications/JavaMonitor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
<dependency>
<groupId>wonder.core</groupId>
<artifactId>ERExtensions</artifactId>
<exclusions>
<exclusion>
<groupId>com.webobjects</groupId>
<artifactId>JavaXML</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>wonder.ajax</groupId>
Expand All @@ -32,6 +38,26 @@
<groupId>wonder.eof</groupId>
<artifactId>ERRest</artifactId>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xmlParserAPIs</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
</dependencies>
<build>
<sourceDirectory>Sources</sourceDirectory>
Expand Down
9 changes: 0 additions & 9 deletions Applications/wotaskd/Resources/Properties
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,3 @@ er.wotaskd.sshd.port=6022

# Enable or disable the built-in SSH/SCP server
er.wotaskd.sshd.enabled=false

log4j.rootCategory=INFO, A1

# A1 is set to be a FileAppender which outputs to System.out.
log4j.appender.A1=org.apache.log4j.ConsoleAppender

# A1 uses PatternLayout.
log4j.appender.A1.layout=er.extensions.logging.ERXPatternLayout
log4j.appender.A1.layout.ConversionPattern=%d %-5p %V{u/f} [%t] %C{2} (%F:%L) - %m%n
14 changes: 14 additions & 0 deletions Applications/wotaskd/Resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%d %-5p %V{u/f} [%t] %C{2} (%F:%L) - %m%n" />
</Console>
</Appenders>
<Loggers>
<Logger name="org.apache.log4j.xml" level="info" />
<Root level="info">
<AppenderRef ref="STDOUT" />
</Root>
</Loggers>
</Configuration>
26 changes: 26 additions & 0 deletions Applications/wotaskd/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,25 @@
<dependency>
<groupId>com.webobjects</groupId>
<artifactId>JavaWebObjects</artifactId>
<exclusions>
<exclusion>
<groupId>com.webobjects</groupId>
<artifactId>JavaXML</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.webobjects</groupId>
<artifactId>JavaEOControl</artifactId>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xmlParserAPIs</artifactId>
</dependency>
<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
Expand All @@ -49,6 +63,18 @@
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-pam</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
</dependencies>
<build>
<sourceDirectory>Sources</sourceDirectory>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package er.examples.movies;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.webobjects.appserver.WOComponent;
import com.webobjects.appserver.WOContext;
import com.webobjects.directtoweb.D2W;
Expand All @@ -13,7 +16,6 @@
import er.directtoweb.interfaces.ERDObjectSaverInterface;
import er.extensions.eof.ERXEC;
import er.extensions.eof.ERXEOControlUtilities;
import er.extensions.logging.ERXLogger;

public class EditOrCreateDirectors extends WOComponent {

Expand Down Expand Up @@ -44,8 +46,8 @@ public WOComponent newDirector() {

public static class CreateDirectorDelegate implements NextPageDelegate {

public static final ERXLogger log = ERXLogger.getERXLogger(CreateDirectorDelegate.class);
public static final Logger log = LoggerFactory.getLogger(CreateDirectorDelegate.class);

protected EOEnterpriseObject movie;
protected WOComponent nextPage;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ public WOActionResults defaultAction() {
_EOMutableKnownKeyDictionary vals;
_EOMutableKnownKeyDictionary.Initializer initializer = new _EOMutableKnownKeyDictionary.Initializer(keys);
vals = new _EOMutableKnownKeyDictionary(initializer);
log.info(vals);
log.info(vals.toString());
vals.setObjectForKey("t1", "test1");
log.info(vals);
log.info(vals.toString());
vals.setObjectForKey("t2", "test2");
log.info(vals);
log.info(vals.toString());
vals.setObjectForKey("t3", "test3");
log.info(vals);
log.info(vals.toString());
vals = new _EOMutableKnownKeyDictionary(initializer, new Object[]{"1", "2"});
log.info(vals);
log.info(vals.toString());
// ERXRemoteNotificationCenter.defaultCenter().postNotification("All", null, dict);
return pageWithName(Main.class);
}
Expand Down
13 changes: 7 additions & 6 deletions Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxRemoteLogging.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package er.ajax;

import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.webobjects.appserver.WOActionResults;
import com.webobjects.appserver.WOAssociation;
Expand Down Expand Up @@ -92,11 +93,8 @@ public WOActionResults performActionNamed(String logger) {
}
// trigger session loading if present
WOSession existing = existingSession();
Logger log = Logger.getLogger(logger);
if ("fatal".equalsIgnoreCase(level)) {
log.fatal(msg);
}
else if ("error".equalsIgnoreCase(level)) {
Logger log = LoggerFactory.getLogger(logger);
if ("error".equalsIgnoreCase(level)) {
log.error(msg);
}
else if ("warn".equalsIgnoreCase(level)) {
Expand All @@ -108,6 +106,9 @@ else if ("info".equalsIgnoreCase(level)) {
else if ("debug".equalsIgnoreCase(level)) {
log.debug(msg);
}
else if ("trace".equalsIgnoreCase(level)) {
log.trace(msg);
}
return new ERXResponse();
}
}
Expand Down
4 changes: 0 additions & 4 deletions Frameworks/Ajax/Ajax/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
<groupId>com.webobjects</groupId>
<artifactId>JavaFoundation</artifactId>
</dependency>
<dependency>
<groupId>com.webobjects</groupId>
<artifactId>JavaXML</artifactId>
</dependency>
<dependency>
<groupId>com.webobjects</groupId>
<artifactId>JavaEOAccess</artifactId>
Expand Down
5 changes: 3 additions & 2 deletions Frameworks/Ajax/ERJQMobile/Sources/er/jqm/ERJQMobile.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package er.jqm;

import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import er.extensions.ERXFrameworkPrincipal;

Expand All @@ -13,7 +14,7 @@ public class ERJQMobile extends ERXFrameworkPrincipal
{
public static Class[] REQUIRES = new Class[0];

public static final Logger log = Logger.getLogger(ERJQMobile.class);
public static final Logger log = LoggerFactory.getLogger(ERJQMobile.class);

public static String frameworkName()
{
Expand Down
Loading