Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvladt2011-03-10 13:30:35 -0500
committervladt2011-03-10 13:31:34 -0500
commitb37f2a1a8337a0ce0cfe094acd397bdffe87a070 (patch)
treeb9f3822abe3e337169b7fc581020b077fa1e2687 /org.eclipse.m2e.logback.appender
parent88c1c7315bd943ed990fb503cfcd8de69eb0b214 (diff)
downloadm2e-core-b37f2a1a8337a0ce0cfe094acd397bdffe87a070.tar.gz
m2e-core-b37f2a1a8337a0ce0cfe094acd397bdffe87a070.tar.xz
m2e-core-b37f2a1a8337a0ce0cfe094acd397bdffe87a070.zip
339567: Log to console only if -consoleLog was passed as arg to eclipse
Diffstat (limited to 'org.eclipse.m2e.logback.appender')
-rw-r--r--org.eclipse.m2e.logback.appender/src/main/java/org/eclipse/m2e/logback/appender/ConsoleAppenderFilter.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/org.eclipse.m2e.logback.appender/src/main/java/org/eclipse/m2e/logback/appender/ConsoleAppenderFilter.java b/org.eclipse.m2e.logback.appender/src/main/java/org/eclipse/m2e/logback/appender/ConsoleAppenderFilter.java
new file mode 100644
index 00000000..ad680b4a
--- /dev/null
+++ b/org.eclipse.m2e.logback.appender/src/main/java/org/eclipse/m2e/logback/appender/ConsoleAppenderFilter.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Sonatype, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.m2e.logback.appender;
+
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.filter.Filter;
+import ch.qos.logback.core.spi.FilterReply;
+
+import org.eclipse.core.runtime.adaptor.EclipseStarter;
+import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
+
+
+/**
+ * Filters out (disables) logging to console if -consoleLog was passed as arg to eclipse
+ */
+@SuppressWarnings("restriction")
+public class ConsoleAppenderFilter extends Filter<ILoggingEvent> {
+ private boolean consoleLogEnabled;
+
+ public ConsoleAppenderFilter() {
+ consoleLogEnabled = "true".equals(FrameworkProperties.getProperty(EclipseStarter.PROP_CONSOLE_LOG));
+ }
+
+ public FilterReply decide(ILoggingEvent loggingEvent) {
+ if(consoleLogEnabled) {
+ return FilterReply.NEUTRAL;
+ }
+ return FilterReply.DENY;
+ }
+}

Back to the top