You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2014/12/05 00:24:01 UTC
[09/53] [abbrv] incubator-ignite git commit: # gg-9470-rename
# gg-9470-rename
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/ee5e27b2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/ee5e27b2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/ee5e27b2
Branch: refs/heads/master
Commit: ee5e27b2fd9719d62b4ee16de2cb8698d91e8e92
Parents: ba7a05d
Author: sboikov <sb...@gridgain.com>
Authored: Thu Dec 4 21:46:25 2014 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Dec 4 21:46:25 2014 +0300
----------------------------------------------------------------------
.../singlesplit/GridSingleSplitsLoadTest.java | 2 +-
.../gridify/GridifySingleSplitLoadTest.java | 2 +-
.../router/GridTcpRouterAbstractSelfTest.java | 2 +-
.../router/GridTcpRouterMultiNodeSelfTest.java | 2 +-
.../src/test/resources/spring-router-ssl.xml | 2 +-
.../src/test/resources/spring-router.xml | 2 +-
.../src/test/resources/spring-server-node.xml | 2 +-
.../test/resources/spring-server-ssl-node.xml | 2 +-
.../child/GridHadoopExternalProcessStarter.java | 2 +-
.../GridLog4jDailyRollingFileAppender.java | 69 +++
.../GridLog4jExternallyRolledFileAppender.java | 55 ++
.../logger/log4j/GridLog4jFileAppender.java | 99 ++++
.../ignite/logger/log4j/GridLog4jFileAware.java | 24 +
.../ignite/logger/log4j/GridLog4jLogger.java | 516 +++++++++++++++++++
.../logger/log4j/GridLog4jNodeIdFilePath.java | 56 ++
.../log4j/GridLog4jRollingFileAppender.java | 82 +++
.../org/apache/ignite/logger/log4j/package.html | 15 +
.../GridLog4jDailyRollingFileAppender.java | 69 ---
.../GridLog4jExternallyRolledFileAppender.java | 55 --
.../logger/log4j/GridLog4jFileAppender.java | 99 ----
.../grid/logger/log4j/GridLog4jFileAware.java | 24 -
.../grid/logger/log4j/GridLog4jLogger.java | 516 -------------------
.../logger/log4j/GridLog4jNodeIdFilePath.java | 56 --
.../log4j/GridLog4jRollingFileAppender.java | 82 ---
.../org/gridgain/grid/logger/log4j/package.html | 15 -
.../log4j/GridLog4jCorrectFileNameTest.java | 1 +
.../logger/log4j/GridLog4jInitializedTest.java | 1 +
.../logger/log4j/GridLog4jLoggingFileTest.java | 1 +
.../logger/log4j/GridLog4jLoggingPathTest.java | 1 +
.../logger/log4j/GridLog4jLoggingUrlTest.java | 1 +
.../log4j/GridLog4jNotInitializedTest.java | 1 +
31 files changed, 931 insertions(+), 925 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/aop/src/test/java/org/gridgain/loadtests/direct/singlesplit/GridSingleSplitsLoadTest.java
----------------------------------------------------------------------
diff --git a/modules/aop/src/test/java/org/gridgain/loadtests/direct/singlesplit/GridSingleSplitsLoadTest.java b/modules/aop/src/test/java/org/gridgain/loadtests/direct/singlesplit/GridSingleSplitsLoadTest.java
index 20137db..75fce32 100644
--- a/modules/aop/src/test/java/org/gridgain/loadtests/direct/singlesplit/GridSingleSplitsLoadTest.java
+++ b/modules/aop/src/test/java/org/gridgain/loadtests/direct/singlesplit/GridSingleSplitsLoadTest.java
@@ -12,10 +12,10 @@ package org.gridgain.loadtests.direct.singlesplit;
import org.apache.ignite.*;
import org.apache.ignite.compute.*;
import org.apache.ignite.configuration.*;
+import org.apache.ignite.logger.log4j.*;
import org.apache.log4j.*;
import org.gridgain.grid.*;
import org.gridgain.grid.loadtest.*;
-import org.gridgain.grid.logger.log4j.*;
import org.gridgain.grid.spi.communication.tcp.*;
import org.gridgain.grid.spi.discovery.tcp.*;
import org.gridgain.grid.util.typedef.*;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/aop/src/test/java/org/gridgain/loadtests/gridify/GridifySingleSplitLoadTest.java
----------------------------------------------------------------------
diff --git a/modules/aop/src/test/java/org/gridgain/loadtests/gridify/GridifySingleSplitLoadTest.java b/modules/aop/src/test/java/org/gridgain/loadtests/gridify/GridifySingleSplitLoadTest.java
index 51187b1..5c53ebb 100644
--- a/modules/aop/src/test/java/org/gridgain/loadtests/gridify/GridifySingleSplitLoadTest.java
+++ b/modules/aop/src/test/java/org/gridgain/loadtests/gridify/GridifySingleSplitLoadTest.java
@@ -11,9 +11,9 @@ package org.gridgain.loadtests.gridify;
import org.apache.ignite.*;
import org.apache.ignite.configuration.*;
+import org.apache.ignite.logger.log4j.*;
import org.apache.log4j.*;
import org.gridgain.grid.loadtest.*;
-import org.gridgain.grid.logger.log4j.*;
import org.gridgain.grid.spi.communication.*;
import org.gridgain.grid.spi.communication.tcp.*;
import org.gridgain.grid.spi.discovery.*;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/clients/src/test/java/org/gridgain/client/router/GridTcpRouterAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/gridgain/client/router/GridTcpRouterAbstractSelfTest.java b/modules/clients/src/test/java/org/gridgain/client/router/GridTcpRouterAbstractSelfTest.java
index ad024d5..76aaac0 100644
--- a/modules/clients/src/test/java/org/gridgain/client/router/GridTcpRouterAbstractSelfTest.java
+++ b/modules/clients/src/test/java/org/gridgain/client/router/GridTcpRouterAbstractSelfTest.java
@@ -9,11 +9,11 @@
package org.gridgain.client.router;
+import org.apache.ignite.logger.log4j.*;
import org.gridgain.client.*;
import org.gridgain.client.integration.*;
import org.gridgain.client.router.impl.*;
import org.gridgain.grid.*;
-import org.gridgain.grid.logger.log4j.*;
import org.gridgain.grid.util.typedef.*;
import java.util.*;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/clients/src/test/java/org/gridgain/client/router/GridTcpRouterMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/gridgain/client/router/GridTcpRouterMultiNodeSelfTest.java b/modules/clients/src/test/java/org/gridgain/client/router/GridTcpRouterMultiNodeSelfTest.java
index 10d0c6c..e71dc0b 100644
--- a/modules/clients/src/test/java/org/gridgain/client/router/GridTcpRouterMultiNodeSelfTest.java
+++ b/modules/clients/src/test/java/org/gridgain/client/router/GridTcpRouterMultiNodeSelfTest.java
@@ -1,10 +1,10 @@
package org.gridgain.client.router;
+import org.apache.ignite.logger.log4j.*;
import org.gridgain.client.*;
import org.gridgain.client.integration.*;
import org.gridgain.client.router.impl.*;
import org.gridgain.grid.*;
-import org.gridgain.grid.logger.log4j.*;
import java.util.*;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/clients/src/test/resources/spring-router-ssl.xml
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/resources/spring-router-ssl.xml b/modules/clients/src/test/resources/spring-router-ssl.xml
index acb48f9..fd10411 100644
--- a/modules/clients/src/test/resources/spring-router-ssl.xml
+++ b/modules/clients/src/test/resources/spring-router-ssl.xml
@@ -92,7 +92,7 @@
<!--
Logger with the same configuration as in default grid instances.
-->
- <bean id="router.log" class="org.gridgain.grid.logger.log4j.GridLog4jLogger">
+ <bean id="router.log" class="org.apache.ignite.logger.log4j.GridLog4jLogger">
<constructor-arg type="java.lang.String" value="modules/clients/src/test/resources/log4j.xml"/>
</bean>
</beans>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/clients/src/test/resources/spring-router.xml
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/resources/spring-router.xml b/modules/clients/src/test/resources/spring-router.xml
index 822946b..671ade5 100644
--- a/modules/clients/src/test/resources/spring-router.xml
+++ b/modules/clients/src/test/resources/spring-router.xml
@@ -81,7 +81,7 @@
<!--
Logger with the same configuration as in default grid instances.
-->
- <bean id="router.log" class="org.gridgain.grid.logger.log4j.GridLog4jLogger">
+ <bean id="router.log" class="org.apache.ignite.logger.log4j.GridLog4jLogger">
<constructor-arg type="java.lang.String" value="modules/clients/src/test/resources/log4j.xml"/>
</bean>
</beans>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/clients/src/test/resources/spring-server-node.xml
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/resources/spring-server-node.xml b/modules/clients/src/test/resources/spring-server-node.xml
index 13df6ac..0068277 100644
--- a/modules/clients/src/test/resources/spring-server-node.xml
+++ b/modules/clients/src/test/resources/spring-server-node.xml
@@ -309,7 +309,7 @@
Logger to use.
-->
<property name="gridLogger">
- <bean class="org.gridgain.grid.logger.log4j.GridLog4jLogger">
+ <bean class="org.apache.ignite.logger.log4j.GridLog4jLogger">
<constructor-arg type="java.lang.String" value="modules/clients/src/test/resources/log4j.xml"/>
</bean>
</property>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/clients/src/test/resources/spring-server-ssl-node.xml
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/resources/spring-server-ssl-node.xml b/modules/clients/src/test/resources/spring-server-ssl-node.xml
index 648ca1a..c2255b4 100644
--- a/modules/clients/src/test/resources/spring-server-ssl-node.xml
+++ b/modules/clients/src/test/resources/spring-server-ssl-node.xml
@@ -276,7 +276,7 @@
Logger to use.
-->
<property name="gridLogger">
- <bean class="org.gridgain.grid.logger.log4j.GridLog4jLogger">
+ <bean class="org.apache.ignite.logger.log4j.GridLog4jLogger">
<constructor-arg type="java.lang.String" value="modules/clients/src/test/resources/log4j.xml"/>
</bean>
</property>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/hadoop/src/main/java/org/gridgain/grid/kernal/processors/hadoop/taskexecutor/external/child/GridHadoopExternalProcessStarter.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/gridgain/grid/kernal/processors/hadoop/taskexecutor/external/child/GridHadoopExternalProcessStarter.java b/modules/hadoop/src/main/java/org/gridgain/grid/kernal/processors/hadoop/taskexecutor/external/child/GridHadoopExternalProcessStarter.java
index 8e0851f..d6bf914 100644
--- a/modules/hadoop/src/main/java/org/gridgain/grid/kernal/processors/hadoop/taskexecutor/external/child/GridHadoopExternalProcessStarter.java
+++ b/modules/hadoop/src/main/java/org/gridgain/grid/kernal/processors/hadoop/taskexecutor/external/child/GridHadoopExternalProcessStarter.java
@@ -11,10 +11,10 @@ package org.gridgain.grid.kernal.processors.hadoop.taskexecutor.external.child;
import org.apache.ignite.*;
import org.apache.ignite.lang.*;
+import org.apache.ignite.logger.log4j.*;
import org.gridgain.grid.*;
import org.gridgain.grid.kernal.processors.hadoop.taskexecutor.external.*;
import org.gridgain.grid.kernal.processors.hadoop.taskexecutor.external.communication.*;
-import org.gridgain.grid.logger.log4j.*;
import org.gridgain.grid.marshaller.optimized.*;
import org.gridgain.grid.util.typedef.internal.*;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jDailyRollingFileAppender.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jDailyRollingFileAppender.java b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jDailyRollingFileAppender.java
new file mode 100644
index 0000000..39722f0
--- /dev/null
+++ b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jDailyRollingFileAppender.java
@@ -0,0 +1,69 @@
+/* @java.file.header */
+
+/* _________ _____ __________________ _____
+ * __ ____/___________(_)______ /__ ____/______ ____(_)_______
+ * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
+ * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
+ * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+ */
+
+package org.apache.ignite.logger.log4j;
+
+import org.apache.ignite.lang.*;
+import org.apache.log4j.*;
+import org.gridgain.grid.util.typedef.internal.*;
+
+import java.io.*;
+
+/**
+ * Log4J {@link DailyRollingFileAppender} with added support for grid node IDs.
+ */
+public class GridLog4jDailyRollingFileAppender extends DailyRollingFileAppender implements GridLog4jFileAware {
+ /** Basic log file name. */
+ private String baseFileName;
+
+ /**
+ * Default constructor (does not do anything).
+ */
+ public GridLog4jDailyRollingFileAppender() {
+ init();
+ }
+
+ /**
+ * Instantiate a FileAppender with given parameters.
+ *
+ * @param layout Layout.
+ * @param filename File name.
+ * @param datePtrn Date pattern.
+ * @throws IOException If failed.
+ */
+ public GridLog4jDailyRollingFileAppender(Layout layout, String filename, String datePtrn) throws IOException {
+ super(layout, filename, datePtrn);
+
+ init();
+ }
+
+ /**
+ *
+ */
+ private void init() {
+ GridLog4jLogger.addAppender(this);
+ }
+
+ /** {@inheritDoc} */
+ @Override public synchronized void updateFilePath(IgniteClosure<String, String> filePathClos) {
+ A.notNull(filePathClos, "filePathClos");
+
+ if (baseFileName == null)
+ baseFileName = fileName;
+
+ fileName = filePathClos.apply(baseFileName);
+ }
+
+ /** {@inheritDoc} */
+ @Override public synchronized void setFile(String fileName, boolean fileAppend, boolean bufIO, int bufSize)
+ throws IOException {
+ if (baseFileName != null)
+ super.setFile(fileName, fileAppend, bufIO, bufSize);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jExternallyRolledFileAppender.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jExternallyRolledFileAppender.java b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jExternallyRolledFileAppender.java
new file mode 100644
index 0000000..95d7da9
--- /dev/null
+++ b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jExternallyRolledFileAppender.java
@@ -0,0 +1,55 @@
+/* @java.file.header */
+
+/* _________ _____ __________________ _____
+ * __ ____/___________(_)______ /__ ____/______ ____(_)_______
+ * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
+ * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
+ * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+ */
+
+package org.apache.ignite.logger.log4j;
+
+import org.apache.ignite.lang.*;
+import org.apache.log4j.varia.*;
+import org.gridgain.grid.util.typedef.internal.*;
+
+import java.io.*;
+
+/**
+ * Log4J {@link ExternallyRolledFileAppender} with added support for grid node IDs.
+ */
+public class GridLog4jExternallyRolledFileAppender extends ExternallyRolledFileAppender implements GridLog4jFileAware {
+ /** Basic log file name. */
+ private String baseFileName;
+
+ /**
+ * Default constructor (does not do anything).
+ */
+ public GridLog4jExternallyRolledFileAppender() {
+ init();
+ }
+
+ /**
+ *
+ */
+ private void init() {
+ GridLog4jLogger.addAppender(this);
+ }
+
+ /** {@inheritDoc} */
+ @Override public synchronized void updateFilePath(IgniteClosure<String, String> filePathClos) {
+ A.notNull(filePathClos, "filePathClos");
+
+ if (baseFileName == null)
+ baseFileName = fileName;
+
+ fileName = filePathClos.apply(baseFileName);
+ }
+
+ /** {@inheritDoc} */
+ @Override public synchronized void setFile(String fileName, boolean fileAppend, boolean bufIO, int bufSize)
+ throws IOException {
+ if (baseFileName != null)
+ super.setFile(fileName, fileAppend, bufIO, bufSize);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jFileAppender.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jFileAppender.java b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jFileAppender.java
new file mode 100644
index 0000000..f6a0aba
--- /dev/null
+++ b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jFileAppender.java
@@ -0,0 +1,99 @@
+/* @java.file.header */
+
+/* _________ _____ __________________ _____
+ * __ ____/___________(_)______ /__ ____/______ ____(_)_______
+ * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
+ * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
+ * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+ */
+
+package org.apache.ignite.logger.log4j;
+
+import org.apache.ignite.lang.*;
+import org.apache.log4j.*;
+import org.gridgain.grid.util.typedef.internal.*;
+
+import java.io.*;
+
+/**
+ * Log4J {@link FileAppender} with added support for grid node IDs.
+ */
+public class GridLog4jFileAppender extends FileAppender implements GridLog4jFileAware {
+ /** Basic log file name. */
+ private String baseFileName;
+
+ /**
+ * Default constructor (does not do anything).
+ */
+ public GridLog4jFileAppender() {
+ init();
+ }
+
+ /**
+ * Instantiate a FileAppender with given parameters.
+ *
+ * @param layout Layout.
+ * @param filename File name.
+ * @throws IOException If failed.
+ */
+ public GridLog4jFileAppender(Layout layout, String filename) throws IOException {
+ super(layout, filename);
+
+ init();
+ }
+
+ /**
+ * Instantiate a FileAppender with given parameters.
+ *
+ * @param layout Layout.
+ * @param filename File name.
+ * @param append Append flag.
+ * @throws IOException If failed.
+ */
+ public GridLog4jFileAppender(Layout layout, String filename, boolean append) throws IOException {
+ super(layout, filename, append);
+
+ init();
+ }
+
+ /**
+ * Instantiate a FileAppender with given parameters.
+ *
+ * @param layout Layout.
+ * @param filename File name.
+ * @param append Append flag.
+ * @param bufIO Buffered IO flag.
+ * @param bufSize Buffer size.
+ * @throws IOException If failed.
+ */
+ public GridLog4jFileAppender(Layout layout, String filename, boolean append, boolean bufIO, int bufSize)
+ throws IOException {
+ super(layout, filename, append, bufIO, bufSize);
+
+ init();
+ }
+
+ /**
+ *
+ */
+ private void init() {
+ GridLog4jLogger.addAppender(this);
+ }
+
+ /** {@inheritDoc} */
+ @Override public synchronized void setFile(String fileName, boolean fileAppend, boolean bufIO, int bufSize)
+ throws IOException {
+ if (baseFileName != null)
+ super.setFile(fileName, fileAppend, bufIO, bufSize);
+ }
+
+ /** {@inheritDoc} */
+ @Override public synchronized void updateFilePath(IgniteClosure<String, String> filePathClos) {
+ A.notNull(filePathClos, "filePathClos");
+
+ if (baseFileName == null)
+ baseFileName = fileName;
+
+ fileName = filePathClos.apply(baseFileName);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jFileAware.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jFileAware.java b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jFileAware.java
new file mode 100644
index 0000000..4e9dc4c
--- /dev/null
+++ b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jFileAware.java
@@ -0,0 +1,24 @@
+/* @java.file.header */
+
+/* _________ _____ __________________ _____
+ * __ ____/___________(_)______ /__ ____/______ ____(_)_______
+ * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
+ * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
+ * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+ */
+
+package org.apache.ignite.logger.log4j;
+
+import org.apache.ignite.lang.*;
+
+/**
+ * Interface for those loggers and appenders that evaluate their file paths lazily.
+ */
+interface GridLog4jFileAware {
+ /**
+ * Sets closure that later evaluate file path.
+ *
+ * @param filePathClos Closure that generates actual file path.
+ */
+ void updateFilePath(IgniteClosure<String, String> filePathClos);
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jLogger.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jLogger.java b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jLogger.java
new file mode 100644
index 0000000..56e7e05
--- /dev/null
+++ b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jLogger.java
@@ -0,0 +1,516 @@
+/* @java.file.header */
+
+/* _________ _____ __________________ _____
+ * __ ____/___________(_)______ /__ ____/______ ____(_)_______
+ * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
+ * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
+ * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+ */
+
+package org.apache.ignite.logger.log4j;
+
+import org.apache.ignite.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.logger.*;
+import org.apache.log4j.*;
+import org.apache.log4j.varia.*;
+import org.apache.log4j.xml.*;
+import org.gridgain.grid.*;
+import org.gridgain.grid.util.*;
+import org.gridgain.grid.util.lang.*;
+import org.gridgain.grid.util.tostring.*;
+import org.gridgain.grid.util.typedef.*;
+import org.gridgain.grid.util.typedef.internal.*;
+import org.jetbrains.annotations.*;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+
+import static org.gridgain.grid.GridSystemProperties.*;
+
+/**
+ * Log4j-based implementation for logging. This logger should be used
+ * by loaders that have prefer <a target=_new href="http://logging.apache.org/log4j/docs/">log4j</a>-based logging.
+ * <p>
+ * Here is a typical example of configuring log4j logger in GridGain configuration file:
+ * <pre name="code" class="xml">
+ * <property name="gridLogger">
+ * <bean class="org.gridgain.grid.logger.log4j.GridLog4jLogger">
+ * <constructor-arg type="java.lang.String" value="config/gridgain-log4j.xml"/>
+ * </bean>
+ * </property>
+ * </pre>
+ * and from your code:
+ * <pre name="code" class="java">
+ * GridConfiguration cfg = new GridConfiguration();
+ * ...
+ * URL xml = U.resolveGridGainUrl("config/custom-log4j.xml");
+ * GridLogger log = new GridLog4jLogger(xml);
+ * ...
+ * cfg.setGridLogger(log);
+ * </pre>
+ *
+ * Please take a look at <a target=_new href="http://logging.apache.org/log4j/1.2/index.html">Apache Log4j 1.2</a>
+ * for additional information.
+ * <p>
+ * It's recommended to use GridGain logger injection instead of using/instantiating
+ * logger in your task/job code. See {@link org.apache.ignite.resources.IgniteLoggerResource} annotation about logger
+ * injection.
+ */
+public class GridLog4jLogger extends GridMetadataAwareAdapter implements IgniteLogger, IgniteLoggerNodeIdAware,
+ GridLog4jFileAware {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Appenders. */
+ private static Collection<FileAppender> fileAppenders = new GridConcurrentHashSet<>();
+
+ /** */
+ private static volatile boolean inited;
+
+ /** */
+ private static volatile boolean quiet0;
+
+ /** */
+ private static final Object mux = new Object();
+
+ /** Logger implementation. */
+ @GridToStringExclude
+ @SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
+ private Logger impl;
+
+ /** Path to configuration file. */
+ private final String path;
+
+ /** Quiet flag. */
+ private final boolean quiet;
+
+ /** Node ID. */
+ private UUID nodeId;
+
+ /**
+ * Creates new logger and automatically detects if root logger already
+ * has appenders configured. If it does not, the root logger will be
+ * configured with default appender (analogous to calling
+ * {@link #GridLog4jLogger(boolean) GridLog4jLogger(boolean)}
+ * with parameter {@code true}, otherwise, existing appenders will be used (analogous
+ * to calling {@link #GridLog4jLogger(boolean) GridLog4jLogger(boolean)}
+ * with parameter {@code false}).
+ */
+ public GridLog4jLogger() {
+ this(!isConfigured());
+ }
+
+ /**
+ * Creates new logger. If initialize parameter is {@code true} the Log4j
+ * logger will be initialized with default console appender and {@code INFO}
+ * log level.
+ *
+ * @param init If {@code true}, then a default console appender with
+ * following pattern layout will be created: {@code %d{ABSOLUTE} %-5p [%c{1}] %m%n}.
+ * If {@code false}, then no implicit initialization will take place,
+ * and {@code Log4j} should be configured prior to calling this
+ * constructor.
+ */
+ public GridLog4jLogger(boolean init) {
+ impl = Logger.getRootLogger();
+
+ if (init) {
+ // Implementation has already been inited, passing NULL.
+ addConsoleAppenderIfNeeded(Level.INFO, null);
+
+ quiet = quiet0;
+ }
+ else
+ quiet = true;
+
+ path = null;
+ }
+
+ /**
+ * Creates new logger with given implementation.
+ *
+ * @param impl Log4j implementation to use.
+ */
+ public GridLog4jLogger(final Logger impl) {
+ assert impl != null;
+
+ path = null;
+
+ addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
+ @Override public Logger apply(Boolean init) {
+ return impl;
+ }
+ });
+
+ quiet = quiet0;
+ }
+
+ /**
+ * Creates new logger with given configuration {@code path}.
+ *
+ * @param path Path to log4j configuration XML file.
+ * @throws GridException Thrown in case logger can't be created.
+ */
+ public GridLog4jLogger(String path) throws GridException {
+ if (path == null)
+ throw new GridException("Configuration XML file for Log4j must be specified.");
+
+ this.path = path;
+
+ final URL cfgUrl = U.resolveGridGainUrl(path);
+
+ if (cfgUrl == null)
+ throw new GridException("Log4j configuration path was not found: " + path);
+
+ addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
+ @Override public Logger apply(Boolean init) {
+ if (init)
+ DOMConfigurator.configure(cfgUrl);
+
+ return Logger.getRootLogger();
+ }
+ });
+
+ quiet = quiet0;
+ }
+
+ /**
+ * Creates new logger with given configuration {@code cfgFile}.
+ *
+ * @param cfgFile Log4j configuration XML file.
+ * @throws GridException Thrown in case logger can't be created.
+ */
+ public GridLog4jLogger(File cfgFile) throws GridException {
+ if (cfgFile == null)
+ throw new GridException("Configuration XML file for Log4j must be specified.");
+
+ if (!cfgFile.exists() || cfgFile.isDirectory())
+ throw new GridException("Log4j configuration path was not found or is a directory: " + cfgFile);
+
+ path = cfgFile.getAbsolutePath();
+
+ addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
+ @Override public Logger apply(Boolean init) {
+ if (init)
+ DOMConfigurator.configure(path);
+
+ return Logger.getRootLogger();
+ }
+ });
+
+ quiet = quiet0;
+ }
+
+ /**
+ * Creates new logger with given configuration {@code cfgUrl}.
+ *
+ * @param cfgUrl URL for Log4j configuration XML file.
+ * @throws GridException Thrown in case logger can't be created.
+ */
+ public GridLog4jLogger(final URL cfgUrl) throws GridException {
+ if (cfgUrl == null)
+ throw new GridException("Configuration XML file for Log4j must be specified.");
+
+ path = null;
+
+ addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
+ @Override public Logger apply(Boolean init) {
+ if (init)
+ DOMConfigurator.configure(cfgUrl);
+
+ return Logger.getRootLogger();
+ }
+ });
+
+ quiet = quiet0;
+ }
+
+ /**
+ * Checks if Log4j is already configured within this VM or not.
+ *
+ * @return {@code True} if log4j was already configured, {@code false} otherwise.
+ */
+ public static boolean isConfigured() {
+ return Logger.getRootLogger().getAllAppenders().hasMoreElements();
+ }
+
+ /**
+ * Sets level for internal log4j implementation.
+ *
+ * @param level Log level to set.
+ */
+ public void setLevel(Level level) {
+ impl.setLevel(level);
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public String fileName() {
+ FileAppender fapp = F.first(fileAppenders);
+
+ return fapp != null ? fapp.getFile() : null;
+ }
+
+ /**
+ * Adds console appender when needed with some default logging settings.
+ *
+ * @param logLevel Optional log level.
+ * @param implInitC Optional log implementation init closure.
+ */
+ private void addConsoleAppenderIfNeeded(@Nullable Level logLevel,
+ @Nullable IgniteClosure<Boolean, Logger> implInitC) {
+ if (inited) {
+ if (implInitC != null)
+ // Do not init.
+ impl = implInitC.apply(false);
+
+ return;
+ }
+
+ synchronized (mux) {
+ if (inited) {
+ if (implInitC != null)
+ // Do not init.
+ impl = implInitC.apply(false);
+
+ return;
+ }
+
+ if (implInitC != null)
+ // Init logger impl.
+ impl = implInitC.apply(true);
+
+ boolean quiet = Boolean.valueOf(System.getProperty(GG_QUIET, "true"));
+
+ boolean consoleAppenderFound = false;
+ Category rootCategory = null;
+ ConsoleAppender errAppender = null;
+
+ for (Category l = impl; l != null; ) {
+ if (!consoleAppenderFound) {
+ for (Enumeration appenders = l.getAllAppenders(); appenders.hasMoreElements(); ) {
+ Appender appender = (Appender)appenders.nextElement();
+
+ if (appender instanceof ConsoleAppender) {
+ if ("CONSOLE_ERR".equals(appender.getName())) {
+ // Treat CONSOLE_ERR appender as a system one and don't count it.
+ errAppender = (ConsoleAppender)appender;
+
+ continue;
+ }
+
+ consoleAppenderFound = true;
+
+ break;
+ }
+ }
+ }
+
+ if (l.getParent() == null) {
+ rootCategory = l;
+
+ break;
+ }
+ else
+ l = l.getParent();
+ }
+
+ if (consoleAppenderFound && quiet)
+ // User configured console appender, but log is quiet.
+ quiet = false;
+
+ if (!consoleAppenderFound && !quiet && Boolean.valueOf(System.getProperty(GG_CONSOLE_APPENDER, "true"))) {
+ // Console appender not found => we've looked through all categories up to root.
+ assert rootCategory != null;
+
+ // User launched gridgain in verbose mode and did not add console appender with INFO level
+ // to configuration and did not set GG_CONSOLE_APPENDER to false.
+ if (errAppender != null) {
+ rootCategory.addAppender(createConsoleAppender(Level.INFO));
+
+ if (errAppender.getThreshold() == Level.ERROR)
+ errAppender.setThreshold(Level.WARN);
+ }
+ else
+ // No error console appender => create console appender with no level limit.
+ rootCategory.addAppender(createConsoleAppender(Level.OFF));
+
+ if (logLevel != null)
+ impl.setLevel(logLevel);
+ }
+
+ quiet0 = quiet;
+ inited = true;
+ }
+ }
+
+ /**
+ * Creates console appender with some reasonable default logging settings.
+ *
+ * @param maxLevel Max logging level.
+ * @return New console appender.
+ */
+ private Appender createConsoleAppender(Level maxLevel) {
+ String fmt = "[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n";
+
+ // Configure output that should go to System.out
+ Appender app = new ConsoleAppender(new PatternLayout(fmt), ConsoleAppender.SYSTEM_OUT);
+
+ LevelRangeFilter lvlFilter = new LevelRangeFilter();
+
+ lvlFilter.setLevelMin(Level.TRACE);
+ lvlFilter.setLevelMax(maxLevel);
+
+ app.addFilter(lvlFilter);
+
+ return app;
+ }
+
+ /**
+ * Adds file appender.
+ *
+ * @param a Appender.
+ */
+ public static void addAppender(FileAppender a) {
+ A.notNull(a, "a");
+
+ fileAppenders.add(a);
+ }
+
+ /**
+ * Removes file appender.
+ *
+ * @param a Appender.
+ */
+ public static void removeAppender(FileAppender a) {
+ A.notNull(a, "a");
+
+ fileAppenders.remove(a);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setNodeId(UUID nodeId) {
+ A.notNull(nodeId, "nodeId");
+
+ this.nodeId = nodeId;
+
+ updateFilePath(new GridLog4jNodeIdFilePath(nodeId));
+ }
+
+ /** {@inheritDoc} */
+ @Override public UUID getNodeId() {
+ return nodeId;
+ }
+
+ /**
+ * Gets files for all registered file appenders.
+ *
+ * @return List of files.
+ */
+ public static Collection<String> logFiles() {
+ Collection<String> res = new ArrayList<>(fileAppenders.size());
+
+ for (FileAppender a : fileAppenders)
+ res.add(a.getFile());
+
+ return res;
+ }
+
+ /**
+ * Gets {@link org.apache.ignite.IgniteLogger} wrapper around log4j logger for the given
+ * category. If category is {@code null}, then root logger is returned. If
+ * category is an instance of {@link Class} then {@code (Class)ctgr).getName()}
+ * is used as category name.
+ *
+ * @param ctgr {@inheritDoc}
+ * @return {@link org.apache.ignite.IgniteLogger} wrapper around log4j logger.
+ */
+ @Override public GridLog4jLogger getLogger(Object ctgr) {
+ return new GridLog4jLogger(ctgr == null ? Logger.getRootLogger() :
+ ctgr instanceof Class ? Logger.getLogger(((Class<?>)ctgr).getName()) :
+ Logger.getLogger(ctgr.toString()));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void trace(String msg) {
+ if (!impl.isTraceEnabled())
+ warning("Logging at TRACE level without checking if TRACE level is enabled: " + msg);
+
+ impl.trace(msg);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void debug(String msg) {
+ if (!impl.isDebugEnabled())
+ warning("Logging at DEBUG level without checking if DEBUG level is enabled: " + msg);
+
+ impl.debug(msg);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void info(String msg) {
+ if (!impl.isInfoEnabled())
+ warning("Logging at INFO level without checking if INFO level is enabled: " + msg);
+
+ impl.info(msg);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void warning(String msg) {
+ impl.warn(msg);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void warning(String msg, @Nullable Throwable e) {
+ impl.warn(msg, e);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void error(String msg) {
+ impl.error(msg);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void error(String msg, @Nullable Throwable e) {
+ impl.error(msg, e);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isTraceEnabled() {
+ return impl.isTraceEnabled();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isDebugEnabled() {
+ return impl.isDebugEnabled();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isInfoEnabled() {
+ return impl.isInfoEnabled();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isQuiet() {
+ return quiet;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(GridLog4jLogger.class, this);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateFilePath(IgniteClosure<String, String> filePathClos) {
+ A.notNull(filePathClos, "filePathClos");
+
+ for (FileAppender a : fileAppenders) {
+ if (a instanceof GridLog4jFileAware) {
+ ((GridLog4jFileAware)a).updateFilePath(filePathClos);
+
+ a.activateOptions();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jNodeIdFilePath.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jNodeIdFilePath.java b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jNodeIdFilePath.java
new file mode 100644
index 0000000..b741808
--- /dev/null
+++ b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jNodeIdFilePath.java
@@ -0,0 +1,56 @@
+/* @java.file.header */
+
+/* _________ _____ __________________ _____
+ * __ ____/___________(_)______ /__ ____/______ ____(_)_______
+ * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
+ * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
+ * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+ */
+
+package org.apache.ignite.logger.log4j;
+
+import org.apache.ignite.lang.*;
+import org.gridgain.grid.*;
+import org.gridgain.grid.util.typedef.*;
+import org.gridgain.grid.util.typedef.internal.*;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * Closure that generates file path adding node id to filename as a suffix.
+ */
+class GridLog4jNodeIdFilePath implements IgniteClosure<String, String> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Node id. */
+ private final UUID nodeId;
+
+ /**
+ * Creates new instance.
+ *
+ * @param id Node id.
+ */
+ GridLog4jNodeIdFilePath(UUID id) {
+ nodeId = id;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String apply(String oldPath) {
+ if (!F.isEmpty(U.GRIDGAIN_LOG_DIR))
+ return U.nodeIdLogFileName(nodeId, new File(U.GRIDGAIN_LOG_DIR, "gridgain.log").getAbsolutePath());
+
+ if (oldPath != null) // fileName could be null if GRIDGAIN_HOME is not defined.
+ return U.nodeIdLogFileName(nodeId, oldPath);
+
+ String tmpDir = GridSystemProperties.getString("java.io.tmpdir");
+
+ if (tmpDir != null)
+ return U.nodeIdLogFileName(nodeId, new File(tmpDir, "gridgain.log").getAbsolutePath());
+
+ System.err.println("Failed to get tmp directory for log file.");
+
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jRollingFileAppender.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jRollingFileAppender.java b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jRollingFileAppender.java
new file mode 100644
index 0000000..cb00de8
--- /dev/null
+++ b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/GridLog4jRollingFileAppender.java
@@ -0,0 +1,82 @@
+/* @java.file.header */
+
+/* _________ _____ __________________ _____
+ * __ ____/___________(_)______ /__ ____/______ ____(_)_______
+ * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
+ * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
+ * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+ */
+
+package org.apache.ignite.logger.log4j;
+
+import org.apache.ignite.lang.*;
+import org.apache.log4j.*;
+import org.gridgain.grid.util.typedef.internal.*;
+
+import java.io.*;
+
+/**
+ * Log4J {@link RollingFileAppender} with added support for grid node IDs.
+ */
+public class GridLog4jRollingFileAppender extends RollingFileAppender implements GridLog4jFileAware {
+ /** Basic log file name. */
+ private String baseFileName;
+
+ /**
+ * Default constructor (does not do anything).
+ */
+ public GridLog4jRollingFileAppender() {
+ init();
+ }
+
+ /**
+ * Instantiate a FileAppender with given parameters.
+ *
+ * @param layout Layout.
+ * @param filename File name.
+ * @throws IOException If failed.
+ */
+ public GridLog4jRollingFileAppender(Layout layout, String filename) throws IOException {
+ super(layout, filename);
+
+ init();
+ }
+
+ /**
+ * Instantiate a FileAppender with given parameters.
+ *
+ * @param layout Layout.
+ * @param filename File name.
+ * @param append Append flag.
+ * @throws IOException If failed.
+ */
+ public GridLog4jRollingFileAppender(Layout layout, String filename, boolean append) throws IOException {
+ super(layout, filename, append);
+
+ init();
+ }
+
+ /**
+ * Initializes appender.
+ */
+ private void init() {
+ GridLog4jLogger.addAppender(this);
+ }
+
+ /** {@inheritDoc} */
+ @Override public synchronized void updateFilePath(IgniteClosure<String, String> filePathClos) {
+ A.notNull(filePathClos, "filePathClos");
+
+ if (baseFileName == null)
+ baseFileName = fileName;
+
+ fileName = filePathClos.apply(baseFileName);
+ }
+
+ /** {@inheritDoc} */
+ @Override public synchronized void setFile(String fileName, boolean fileAppend, boolean bufIO, int bufSize)
+ throws IOException {
+ if (baseFileName != null)
+ super.setFile(fileName, fileAppend, bufIO, bufSize);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/package.html
----------------------------------------------------------------------
diff --git a/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/package.html b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/package.html
new file mode 100644
index 0000000..e6e24ee
--- /dev/null
+++ b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/package.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!--
+ @html.file.header
+ _________ _____ __________________ _____
+ __ ____/___________(_)______ /__ ____/______ ____(_)_______
+ _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
+ / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
+ \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+-->
+<html>
+<body>
+ <!-- Package description. -->
+ Contains <b>default</b> Log4j implementation for logging.
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jDailyRollingFileAppender.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jDailyRollingFileAppender.java b/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jDailyRollingFileAppender.java
deleted file mode 100644
index 9320eaf..0000000
--- a/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jDailyRollingFileAppender.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/* @java.file.header */
-
-/* _________ _____ __________________ _____
- * __ ____/___________(_)______ /__ ____/______ ____(_)_______
- * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
- * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
- * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
- */
-
-package org.gridgain.grid.logger.log4j;
-
-import org.apache.ignite.lang.*;
-import org.apache.log4j.*;
-import org.gridgain.grid.util.typedef.internal.*;
-
-import java.io.*;
-
-/**
- * Log4J {@link DailyRollingFileAppender} with added support for grid node IDs.
- */
-public class GridLog4jDailyRollingFileAppender extends DailyRollingFileAppender implements GridLog4jFileAware {
- /** Basic log file name. */
- private String baseFileName;
-
- /**
- * Default constructor (does not do anything).
- */
- public GridLog4jDailyRollingFileAppender() {
- init();
- }
-
- /**
- * Instantiate a FileAppender with given parameters.
- *
- * @param layout Layout.
- * @param filename File name.
- * @param datePtrn Date pattern.
- * @throws IOException If failed.
- */
- public GridLog4jDailyRollingFileAppender(Layout layout, String filename, String datePtrn) throws IOException {
- super(layout, filename, datePtrn);
-
- init();
- }
-
- /**
- *
- */
- private void init() {
- GridLog4jLogger.addAppender(this);
- }
-
- /** {@inheritDoc} */
- @Override public synchronized void updateFilePath(IgniteClosure<String, String> filePathClos) {
- A.notNull(filePathClos, "filePathClos");
-
- if (baseFileName == null)
- baseFileName = fileName;
-
- fileName = filePathClos.apply(baseFileName);
- }
-
- /** {@inheritDoc} */
- @Override public synchronized void setFile(String fileName, boolean fileAppend, boolean bufIO, int bufSize)
- throws IOException {
- if (baseFileName != null)
- super.setFile(fileName, fileAppend, bufIO, bufSize);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jExternallyRolledFileAppender.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jExternallyRolledFileAppender.java b/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jExternallyRolledFileAppender.java
deleted file mode 100644
index 76269d1..0000000
--- a/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jExternallyRolledFileAppender.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/* @java.file.header */
-
-/* _________ _____ __________________ _____
- * __ ____/___________(_)______ /__ ____/______ ____(_)_______
- * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
- * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
- * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
- */
-
-package org.gridgain.grid.logger.log4j;
-
-import org.apache.ignite.lang.*;
-import org.apache.log4j.varia.*;
-import org.gridgain.grid.util.typedef.internal.*;
-
-import java.io.*;
-
-/**
- * Log4J {@link ExternallyRolledFileAppender} with added support for grid node IDs.
- */
-public class GridLog4jExternallyRolledFileAppender extends ExternallyRolledFileAppender implements GridLog4jFileAware {
- /** Basic log file name. */
- private String baseFileName;
-
- /**
- * Default constructor (does not do anything).
- */
- public GridLog4jExternallyRolledFileAppender() {
- init();
- }
-
- /**
- *
- */
- private void init() {
- GridLog4jLogger.addAppender(this);
- }
-
- /** {@inheritDoc} */
- @Override public synchronized void updateFilePath(IgniteClosure<String, String> filePathClos) {
- A.notNull(filePathClos, "filePathClos");
-
- if (baseFileName == null)
- baseFileName = fileName;
-
- fileName = filePathClos.apply(baseFileName);
- }
-
- /** {@inheritDoc} */
- @Override public synchronized void setFile(String fileName, boolean fileAppend, boolean bufIO, int bufSize)
- throws IOException {
- if (baseFileName != null)
- super.setFile(fileName, fileAppend, bufIO, bufSize);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jFileAppender.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jFileAppender.java b/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jFileAppender.java
deleted file mode 100644
index a54b54d..0000000
--- a/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jFileAppender.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/* @java.file.header */
-
-/* _________ _____ __________________ _____
- * __ ____/___________(_)______ /__ ____/______ ____(_)_______
- * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
- * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
- * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
- */
-
-package org.gridgain.grid.logger.log4j;
-
-import org.apache.ignite.lang.*;
-import org.apache.log4j.*;
-import org.gridgain.grid.util.typedef.internal.*;
-
-import java.io.*;
-
-/**
- * Log4J {@link FileAppender} with added support for grid node IDs.
- */
-public class GridLog4jFileAppender extends FileAppender implements GridLog4jFileAware {
- /** Basic log file name. */
- private String baseFileName;
-
- /**
- * Default constructor (does not do anything).
- */
- public GridLog4jFileAppender() {
- init();
- }
-
- /**
- * Instantiate a FileAppender with given parameters.
- *
- * @param layout Layout.
- * @param filename File name.
- * @throws IOException If failed.
- */
- public GridLog4jFileAppender(Layout layout, String filename) throws IOException {
- super(layout, filename);
-
- init();
- }
-
- /**
- * Instantiate a FileAppender with given parameters.
- *
- * @param layout Layout.
- * @param filename File name.
- * @param append Append flag.
- * @throws IOException If failed.
- */
- public GridLog4jFileAppender(Layout layout, String filename, boolean append) throws IOException {
- super(layout, filename, append);
-
- init();
- }
-
- /**
- * Instantiate a FileAppender with given parameters.
- *
- * @param layout Layout.
- * @param filename File name.
- * @param append Append flag.
- * @param bufIO Buffered IO flag.
- * @param bufSize Buffer size.
- * @throws IOException If failed.
- */
- public GridLog4jFileAppender(Layout layout, String filename, boolean append, boolean bufIO, int bufSize)
- throws IOException {
- super(layout, filename, append, bufIO, bufSize);
-
- init();
- }
-
- /**
- *
- */
- private void init() {
- GridLog4jLogger.addAppender(this);
- }
-
- /** {@inheritDoc} */
- @Override public synchronized void setFile(String fileName, boolean fileAppend, boolean bufIO, int bufSize)
- throws IOException {
- if (baseFileName != null)
- super.setFile(fileName, fileAppend, bufIO, bufSize);
- }
-
- /** {@inheritDoc} */
- @Override public synchronized void updateFilePath(IgniteClosure<String, String> filePathClos) {
- A.notNull(filePathClos, "filePathClos");
-
- if (baseFileName == null)
- baseFileName = fileName;
-
- fileName = filePathClos.apply(baseFileName);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jFileAware.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jFileAware.java b/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jFileAware.java
deleted file mode 100644
index 63b89e2..0000000
--- a/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jFileAware.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/* @java.file.header */
-
-/* _________ _____ __________________ _____
- * __ ____/___________(_)______ /__ ____/______ ____(_)_______
- * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
- * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
- * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
- */
-
-package org.gridgain.grid.logger.log4j;
-
-import org.apache.ignite.lang.*;
-
-/**
- * Interface for those loggers and appenders that evaluate their file paths lazily.
- */
-interface GridLog4jFileAware {
- /**
- * Sets closure that later evaluate file path.
- *
- * @param filePathClos Closure that generates actual file path.
- */
- void updateFilePath(IgniteClosure<String, String> filePathClos);
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jLogger.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jLogger.java b/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jLogger.java
deleted file mode 100644
index c0bbdaa..0000000
--- a/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jLogger.java
+++ /dev/null
@@ -1,516 +0,0 @@
-/* @java.file.header */
-
-/* _________ _____ __________________ _____
- * __ ____/___________(_)______ /__ ____/______ ____(_)_______
- * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
- * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
- * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
- */
-
-package org.gridgain.grid.logger.log4j;
-
-import org.apache.ignite.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.logger.*;
-import org.apache.log4j.*;
-import org.apache.log4j.varia.*;
-import org.apache.log4j.xml.*;
-import org.gridgain.grid.*;
-import org.gridgain.grid.util.*;
-import org.gridgain.grid.util.lang.*;
-import org.gridgain.grid.util.tostring.*;
-import org.gridgain.grid.util.typedef.*;
-import org.gridgain.grid.util.typedef.internal.*;
-import org.jetbrains.annotations.*;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-import static org.gridgain.grid.GridSystemProperties.*;
-
-/**
- * Log4j-based implementation for logging. This logger should be used
- * by loaders that have prefer <a target=_new href="http://logging.apache.org/log4j/docs/">log4j</a>-based logging.
- * <p>
- * Here is a typical example of configuring log4j logger in GridGain configuration file:
- * <pre name="code" class="xml">
- * <property name="gridLogger">
- * <bean class="org.gridgain.grid.logger.log4j.GridLog4jLogger">
- * <constructor-arg type="java.lang.String" value="config/gridgain-log4j.xml"/>
- * </bean>
- * </property>
- * </pre>
- * and from your code:
- * <pre name="code" class="java">
- * GridConfiguration cfg = new GridConfiguration();
- * ...
- * URL xml = U.resolveGridGainUrl("config/custom-log4j.xml");
- * GridLogger log = new GridLog4jLogger(xml);
- * ...
- * cfg.setGridLogger(log);
- * </pre>
- *
- * Please take a look at <a target=_new href="http://logging.apache.org/log4j/1.2/index.html">Apache Log4j 1.2</a>
- * for additional information.
- * <p>
- * It's recommended to use GridGain logger injection instead of using/instantiating
- * logger in your task/job code. See {@link org.apache.ignite.resources.IgniteLoggerResource} annotation about logger
- * injection.
- */
-public class GridLog4jLogger extends GridMetadataAwareAdapter implements IgniteLogger, IgniteLoggerNodeIdAware,
- GridLog4jFileAware {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Appenders. */
- private static Collection<FileAppender> fileAppenders = new GridConcurrentHashSet<>();
-
- /** */
- private static volatile boolean inited;
-
- /** */
- private static volatile boolean quiet0;
-
- /** */
- private static final Object mux = new Object();
-
- /** Logger implementation. */
- @GridToStringExclude
- @SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
- private Logger impl;
-
- /** Path to configuration file. */
- private final String path;
-
- /** Quiet flag. */
- private final boolean quiet;
-
- /** Node ID. */
- private UUID nodeId;
-
- /**
- * Creates new logger and automatically detects if root logger already
- * has appenders configured. If it does not, the root logger will be
- * configured with default appender (analogous to calling
- * {@link #GridLog4jLogger(boolean) GridLog4jLogger(boolean)}
- * with parameter {@code true}, otherwise, existing appenders will be used (analogous
- * to calling {@link #GridLog4jLogger(boolean) GridLog4jLogger(boolean)}
- * with parameter {@code false}).
- */
- public GridLog4jLogger() {
- this(!isConfigured());
- }
-
- /**
- * Creates new logger. If initialize parameter is {@code true} the Log4j
- * logger will be initialized with default console appender and {@code INFO}
- * log level.
- *
- * @param init If {@code true}, then a default console appender with
- * following pattern layout will be created: {@code %d{ABSOLUTE} %-5p [%c{1}] %m%n}.
- * If {@code false}, then no implicit initialization will take place,
- * and {@code Log4j} should be configured prior to calling this
- * constructor.
- */
- public GridLog4jLogger(boolean init) {
- impl = Logger.getRootLogger();
-
- if (init) {
- // Implementation has already been inited, passing NULL.
- addConsoleAppenderIfNeeded(Level.INFO, null);
-
- quiet = quiet0;
- }
- else
- quiet = true;
-
- path = null;
- }
-
- /**
- * Creates new logger with given implementation.
- *
- * @param impl Log4j implementation to use.
- */
- public GridLog4jLogger(final Logger impl) {
- assert impl != null;
-
- path = null;
-
- addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
- @Override public Logger apply(Boolean init) {
- return impl;
- }
- });
-
- quiet = quiet0;
- }
-
- /**
- * Creates new logger with given configuration {@code path}.
- *
- * @param path Path to log4j configuration XML file.
- * @throws GridException Thrown in case logger can't be created.
- */
- public GridLog4jLogger(String path) throws GridException {
- if (path == null)
- throw new GridException("Configuration XML file for Log4j must be specified.");
-
- this.path = path;
-
- final URL cfgUrl = U.resolveGridGainUrl(path);
-
- if (cfgUrl == null)
- throw new GridException("Log4j configuration path was not found: " + path);
-
- addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
- @Override public Logger apply(Boolean init) {
- if (init)
- DOMConfigurator.configure(cfgUrl);
-
- return Logger.getRootLogger();
- }
- });
-
- quiet = quiet0;
- }
-
- /**
- * Creates new logger with given configuration {@code cfgFile}.
- *
- * @param cfgFile Log4j configuration XML file.
- * @throws GridException Thrown in case logger can't be created.
- */
- public GridLog4jLogger(File cfgFile) throws GridException {
- if (cfgFile == null)
- throw new GridException("Configuration XML file for Log4j must be specified.");
-
- if (!cfgFile.exists() || cfgFile.isDirectory())
- throw new GridException("Log4j configuration path was not found or is a directory: " + cfgFile);
-
- path = cfgFile.getAbsolutePath();
-
- addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
- @Override public Logger apply(Boolean init) {
- if (init)
- DOMConfigurator.configure(path);
-
- return Logger.getRootLogger();
- }
- });
-
- quiet = quiet0;
- }
-
- /**
- * Creates new logger with given configuration {@code cfgUrl}.
- *
- * @param cfgUrl URL for Log4j configuration XML file.
- * @throws GridException Thrown in case logger can't be created.
- */
- public GridLog4jLogger(final URL cfgUrl) throws GridException {
- if (cfgUrl == null)
- throw new GridException("Configuration XML file for Log4j must be specified.");
-
- path = null;
-
- addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
- @Override public Logger apply(Boolean init) {
- if (init)
- DOMConfigurator.configure(cfgUrl);
-
- return Logger.getRootLogger();
- }
- });
-
- quiet = quiet0;
- }
-
- /**
- * Checks if Log4j is already configured within this VM or not.
- *
- * @return {@code True} if log4j was already configured, {@code false} otherwise.
- */
- public static boolean isConfigured() {
- return Logger.getRootLogger().getAllAppenders().hasMoreElements();
- }
-
- /**
- * Sets level for internal log4j implementation.
- *
- * @param level Log level to set.
- */
- public void setLevel(Level level) {
- impl.setLevel(level);
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public String fileName() {
- FileAppender fapp = F.first(fileAppenders);
-
- return fapp != null ? fapp.getFile() : null;
- }
-
- /**
- * Adds console appender when needed with some default logging settings.
- *
- * @param logLevel Optional log level.
- * @param implInitC Optional log implementation init closure.
- */
- private void addConsoleAppenderIfNeeded(@Nullable Level logLevel,
- @Nullable IgniteClosure<Boolean, Logger> implInitC) {
- if (inited) {
- if (implInitC != null)
- // Do not init.
- impl = implInitC.apply(false);
-
- return;
- }
-
- synchronized (mux) {
- if (inited) {
- if (implInitC != null)
- // Do not init.
- impl = implInitC.apply(false);
-
- return;
- }
-
- if (implInitC != null)
- // Init logger impl.
- impl = implInitC.apply(true);
-
- boolean quiet = Boolean.valueOf(System.getProperty(GG_QUIET, "true"));
-
- boolean consoleAppenderFound = false;
- Category rootCategory = null;
- ConsoleAppender errAppender = null;
-
- for (Category l = impl; l != null; ) {
- if (!consoleAppenderFound) {
- for (Enumeration appenders = l.getAllAppenders(); appenders.hasMoreElements(); ) {
- Appender appender = (Appender)appenders.nextElement();
-
- if (appender instanceof ConsoleAppender) {
- if ("CONSOLE_ERR".equals(appender.getName())) {
- // Treat CONSOLE_ERR appender as a system one and don't count it.
- errAppender = (ConsoleAppender)appender;
-
- continue;
- }
-
- consoleAppenderFound = true;
-
- break;
- }
- }
- }
-
- if (l.getParent() == null) {
- rootCategory = l;
-
- break;
- }
- else
- l = l.getParent();
- }
-
- if (consoleAppenderFound && quiet)
- // User configured console appender, but log is quiet.
- quiet = false;
-
- if (!consoleAppenderFound && !quiet && Boolean.valueOf(System.getProperty(GG_CONSOLE_APPENDER, "true"))) {
- // Console appender not found => we've looked through all categories up to root.
- assert rootCategory != null;
-
- // User launched gridgain in verbose mode and did not add console appender with INFO level
- // to configuration and did not set GG_CONSOLE_APPENDER to false.
- if (errAppender != null) {
- rootCategory.addAppender(createConsoleAppender(Level.INFO));
-
- if (errAppender.getThreshold() == Level.ERROR)
- errAppender.setThreshold(Level.WARN);
- }
- else
- // No error console appender => create console appender with no level limit.
- rootCategory.addAppender(createConsoleAppender(Level.OFF));
-
- if (logLevel != null)
- impl.setLevel(logLevel);
- }
-
- quiet0 = quiet;
- inited = true;
- }
- }
-
- /**
- * Creates console appender with some reasonable default logging settings.
- *
- * @param maxLevel Max logging level.
- * @return New console appender.
- */
- private Appender createConsoleAppender(Level maxLevel) {
- String fmt = "[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n";
-
- // Configure output that should go to System.out
- Appender app = new ConsoleAppender(new PatternLayout(fmt), ConsoleAppender.SYSTEM_OUT);
-
- LevelRangeFilter lvlFilter = new LevelRangeFilter();
-
- lvlFilter.setLevelMin(Level.TRACE);
- lvlFilter.setLevelMax(maxLevel);
-
- app.addFilter(lvlFilter);
-
- return app;
- }
-
- /**
- * Adds file appender.
- *
- * @param a Appender.
- */
- public static void addAppender(FileAppender a) {
- A.notNull(a, "a");
-
- fileAppenders.add(a);
- }
-
- /**
- * Removes file appender.
- *
- * @param a Appender.
- */
- public static void removeAppender(FileAppender a) {
- A.notNull(a, "a");
-
- fileAppenders.remove(a);
- }
-
- /** {@inheritDoc} */
- @Override public void setNodeId(UUID nodeId) {
- A.notNull(nodeId, "nodeId");
-
- this.nodeId = nodeId;
-
- updateFilePath(new GridLog4jNodeIdFilePath(nodeId));
- }
-
- /** {@inheritDoc} */
- @Override public UUID getNodeId() {
- return nodeId;
- }
-
- /**
- * Gets files for all registered file appenders.
- *
- * @return List of files.
- */
- public static Collection<String> logFiles() {
- Collection<String> res = new ArrayList<>(fileAppenders.size());
-
- for (FileAppender a : fileAppenders)
- res.add(a.getFile());
-
- return res;
- }
-
- /**
- * Gets {@link org.apache.ignite.IgniteLogger} wrapper around log4j logger for the given
- * category. If category is {@code null}, then root logger is returned. If
- * category is an instance of {@link Class} then {@code (Class)ctgr).getName()}
- * is used as category name.
- *
- * @param ctgr {@inheritDoc}
- * @return {@link org.apache.ignite.IgniteLogger} wrapper around log4j logger.
- */
- @Override public GridLog4jLogger getLogger(Object ctgr) {
- return new GridLog4jLogger(ctgr == null ? Logger.getRootLogger() :
- ctgr instanceof Class ? Logger.getLogger(((Class<?>)ctgr).getName()) :
- Logger.getLogger(ctgr.toString()));
- }
-
- /** {@inheritDoc} */
- @Override public void trace(String msg) {
- if (!impl.isTraceEnabled())
- warning("Logging at TRACE level without checking if TRACE level is enabled: " + msg);
-
- impl.trace(msg);
- }
-
- /** {@inheritDoc} */
- @Override public void debug(String msg) {
- if (!impl.isDebugEnabled())
- warning("Logging at DEBUG level without checking if DEBUG level is enabled: " + msg);
-
- impl.debug(msg);
- }
-
- /** {@inheritDoc} */
- @Override public void info(String msg) {
- if (!impl.isInfoEnabled())
- warning("Logging at INFO level without checking if INFO level is enabled: " + msg);
-
- impl.info(msg);
- }
-
- /** {@inheritDoc} */
- @Override public void warning(String msg) {
- impl.warn(msg);
- }
-
- /** {@inheritDoc} */
- @Override public void warning(String msg, @Nullable Throwable e) {
- impl.warn(msg, e);
- }
-
- /** {@inheritDoc} */
- @Override public void error(String msg) {
- impl.error(msg);
- }
-
- /** {@inheritDoc} */
- @Override public void error(String msg, @Nullable Throwable e) {
- impl.error(msg, e);
- }
-
- /** {@inheritDoc} */
- @Override public boolean isTraceEnabled() {
- return impl.isTraceEnabled();
- }
-
- /** {@inheritDoc} */
- @Override public boolean isDebugEnabled() {
- return impl.isDebugEnabled();
- }
-
- /** {@inheritDoc} */
- @Override public boolean isInfoEnabled() {
- return impl.isInfoEnabled();
- }
-
- /** {@inheritDoc} */
- @Override public boolean isQuiet() {
- return quiet;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridLog4jLogger.class, this);
- }
-
- /** {@inheritDoc} */
- @Override public void updateFilePath(IgniteClosure<String, String> filePathClos) {
- A.notNull(filePathClos, "filePathClos");
-
- for (FileAppender a : fileAppenders) {
- if (a instanceof GridLog4jFileAware) {
- ((GridLog4jFileAware)a).updateFilePath(filePathClos);
-
- a.activateOptions();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jNodeIdFilePath.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jNodeIdFilePath.java b/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jNodeIdFilePath.java
deleted file mode 100644
index 7d6c3dd..0000000
--- a/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jNodeIdFilePath.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* @java.file.header */
-
-/* _________ _____ __________________ _____
- * __ ____/___________(_)______ /__ ____/______ ____(_)_______
- * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
- * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
- * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
- */
-
-package org.gridgain.grid.logger.log4j;
-
-import org.apache.ignite.lang.*;
-import org.gridgain.grid.*;
-import org.gridgain.grid.util.typedef.*;
-import org.gridgain.grid.util.typedef.internal.*;
-
-import java.io.*;
-import java.util.*;
-
-/**
- * Closure that generates file path adding node id to filename as a suffix.
- */
-class GridLog4jNodeIdFilePath implements IgniteClosure<String, String> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Node id. */
- private final UUID nodeId;
-
- /**
- * Creates new instance.
- *
- * @param id Node id.
- */
- GridLog4jNodeIdFilePath(UUID id) {
- nodeId = id;
- }
-
- /** {@inheritDoc} */
- @Override public String apply(String oldPath) {
- if (!F.isEmpty(U.GRIDGAIN_LOG_DIR))
- return U.nodeIdLogFileName(nodeId, new File(U.GRIDGAIN_LOG_DIR, "gridgain.log").getAbsolutePath());
-
- if (oldPath != null) // fileName could be null if GRIDGAIN_HOME is not defined.
- return U.nodeIdLogFileName(nodeId, oldPath);
-
- String tmpDir = GridSystemProperties.getString("java.io.tmpdir");
-
- if (tmpDir != null)
- return U.nodeIdLogFileName(nodeId, new File(tmpDir, "gridgain.log").getAbsolutePath());
-
- System.err.println("Failed to get tmp directory for log file.");
-
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jRollingFileAppender.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jRollingFileAppender.java b/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jRollingFileAppender.java
deleted file mode 100644
index 91e8672..0000000
--- a/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/GridLog4jRollingFileAppender.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/* @java.file.header */
-
-/* _________ _____ __________________ _____
- * __ ____/___________(_)______ /__ ____/______ ____(_)_______
- * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
- * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
- * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
- */
-
-package org.gridgain.grid.logger.log4j;
-
-import org.apache.ignite.lang.*;
-import org.apache.log4j.*;
-import org.gridgain.grid.util.typedef.internal.*;
-
-import java.io.*;
-
-/**
- * Log4J {@link RollingFileAppender} with added support for grid node IDs.
- */
-public class GridLog4jRollingFileAppender extends RollingFileAppender implements GridLog4jFileAware {
- /** Basic log file name. */
- private String baseFileName;
-
- /**
- * Default constructor (does not do anything).
- */
- public GridLog4jRollingFileAppender() {
- init();
- }
-
- /**
- * Instantiate a FileAppender with given parameters.
- *
- * @param layout Layout.
- * @param filename File name.
- * @throws IOException If failed.
- */
- public GridLog4jRollingFileAppender(Layout layout, String filename) throws IOException {
- super(layout, filename);
-
- init();
- }
-
- /**
- * Instantiate a FileAppender with given parameters.
- *
- * @param layout Layout.
- * @param filename File name.
- * @param append Append flag.
- * @throws IOException If failed.
- */
- public GridLog4jRollingFileAppender(Layout layout, String filename, boolean append) throws IOException {
- super(layout, filename, append);
-
- init();
- }
-
- /**
- * Initializes appender.
- */
- private void init() {
- GridLog4jLogger.addAppender(this);
- }
-
- /** {@inheritDoc} */
- @Override public synchronized void updateFilePath(IgniteClosure<String, String> filePathClos) {
- A.notNull(filePathClos, "filePathClos");
-
- if (baseFileName == null)
- baseFileName = fileName;
-
- fileName = filePathClos.apply(baseFileName);
- }
-
- /** {@inheritDoc} */
- @Override public synchronized void setFile(String fileName, boolean fileAppend, boolean bufIO, int bufSize)
- throws IOException {
- if (baseFileName != null)
- super.setFile(fileName, fileAppend, bufIO, bufSize);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/package.html
----------------------------------------------------------------------
diff --git a/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/package.html b/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/package.html
deleted file mode 100644
index e6e24ee..0000000
--- a/modules/log4j/src/main/java/org/gridgain/grid/logger/log4j/package.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<!--
- @html.file.header
- _________ _____ __________________ _____
- __ ____/___________(_)______ /__ ____/______ ____(_)_______
- _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
- / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
- \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
--->
-<html>
-<body>
- <!-- Package description. -->
- Contains <b>default</b> Log4j implementation for logging.
-</body>
-</html>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jCorrectFileNameTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jCorrectFileNameTest.java b/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jCorrectFileNameTest.java
index 357e552..83a5d3b 100644
--- a/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jCorrectFileNameTest.java
+++ b/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jCorrectFileNameTest.java
@@ -12,6 +12,7 @@ package org.gridgain.grid.logger.log4j;
import junit.framework.*;
import org.apache.ignite.*;
import org.apache.ignite.configuration.*;
+import org.apache.ignite.logger.log4j.*;
import org.apache.log4j.*;
import org.apache.log4j.varia.*;
import org.gridgain.grid.util.typedef.*;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jInitializedTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jInitializedTest.java b/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jInitializedTest.java
index c092abe..54ea5c1 100644
--- a/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jInitializedTest.java
+++ b/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jInitializedTest.java
@@ -11,6 +11,7 @@ package org.gridgain.grid.logger.log4j;
import junit.framework.*;
import org.apache.ignite.*;
+import org.apache.ignite.logger.log4j.*;
import org.apache.log4j.*;
import org.gridgain.testframework.junits.common.*;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jLoggingFileTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jLoggingFileTest.java b/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jLoggingFileTest.java
index 32f0355..fa82eb1 100644
--- a/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jLoggingFileTest.java
+++ b/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jLoggingFileTest.java
@@ -11,6 +11,7 @@ package org.gridgain.grid.logger.log4j;
import junit.framework.*;
import org.apache.ignite.*;
+import org.apache.ignite.logger.log4j.*;
import org.gridgain.testframework.*;
import org.gridgain.testframework.junits.common.*;
import java.io.*;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jLoggingPathTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jLoggingPathTest.java b/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jLoggingPathTest.java
index 27780f7..0457d54 100644
--- a/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jLoggingPathTest.java
+++ b/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jLoggingPathTest.java
@@ -11,6 +11,7 @@ package org.gridgain.grid.logger.log4j;
import junit.framework.*;
import org.apache.ignite.*;
+import org.apache.ignite.logger.log4j.*;
import org.gridgain.testframework.junits.common.*;
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jLoggingUrlTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jLoggingUrlTest.java b/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jLoggingUrlTest.java
index 0cf5590..951b920 100644
--- a/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jLoggingUrlTest.java
+++ b/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jLoggingUrlTest.java
@@ -11,6 +11,7 @@ package org.gridgain.grid.logger.log4j;
import junit.framework.*;
import org.apache.ignite.*;
+import org.apache.ignite.logger.log4j.*;
import org.gridgain.testframework.*;
import org.gridgain.testframework.junits.common.*;
import java.io.*;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ee5e27b2/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jNotInitializedTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jNotInitializedTest.java b/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jNotInitializedTest.java
index 1c89be9..2b5a0a9 100644
--- a/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jNotInitializedTest.java
+++ b/modules/log4j/src/test/java/org/gridgain/grid/logger/log4j/GridLog4jNotInitializedTest.java
@@ -11,6 +11,7 @@ package org.gridgain.grid.logger.log4j;
import junit.framework.*;
import org.apache.ignite.*;
+import org.apache.ignite.logger.log4j.*;
import org.gridgain.testframework.junits.common.*;
/**