Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2010-12-17 21:29:06 +0000
committerPascal Rapicault2010-12-17 21:29:06 +0000
commitdedc0450104015cb3b5c3a282c11040fd41dddf6 (patch)
treece51799fbe9603a8a28eabbad900ef53c9382f68
parentb8c7845024b97f7795c6140925dadad56527ff60 (diff)
downloadm2e-core-dedc0450104015cb3b5c3a282c11040fd41dddf6.tar.gz
m2e-core-dedc0450104015cb3b5c3a282c11040fd41dddf6.tar.xz
m2e-core-dedc0450104015cb3b5c3a282c11040fd41dddf6.zip
add logging bundle
-rw-r--r--org.eclipse.m2e.logging/.classpath7
-rw-r--r--org.eclipse.m2e.logging/.project28
-rw-r--r--org.eclipse.m2e.logging/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--org.eclipse.m2e.logging/META-INF/MANIFEST.MF12
-rw-r--r--org.eclipse.m2e.logging/bin/org/eclipse/m2e/internal/logging/LogPlugin.classbin0 -> 3933 bytes
-rw-r--r--org.eclipse.m2e.logging/build.properties5
-rw-r--r--org.eclipse.m2e.logging/defaultLogbackConfiguration/logback.xml29
-rw-r--r--org.eclipse.m2e.logging/src/org/eclipse/m2e/internal/logging/LogPlugin.java96
8 files changed, 185 insertions, 0 deletions
diff --git a/org.eclipse.m2e.logging/.classpath b/org.eclipse.m2e.logging/.classpath
new file mode 100644
index 00000000..ad32c83a
--- /dev/null
+++ b/org.eclipse.m2e.logging/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.m2e.logging/.project b/org.eclipse.m2e.logging/.project
new file mode 100644
index 00000000..79dadda6
--- /dev/null
+++ b/org.eclipse.m2e.logging/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.m2e.logging</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.m2e.logging/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.m2e.logging/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..d79b6443
--- /dev/null
+++ b/org.eclipse.m2e.logging/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Fri Dec 17 15:19:34 EST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/org.eclipse.m2e.logging/META-INF/MANIFEST.MF b/org.eclipse.m2e.logging/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..c505b779
--- /dev/null
+++ b/org.eclipse.m2e.logging/META-INF/MANIFEST.MF
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: m2e logging configuration
+Bundle-SymbolicName: org.eclipse.m2e.logging
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.m2e.internal.logging.LogPlugin
+Require-Bundle: org.eclipse.core.runtime;bundle-version="3.5.0",
+ ch.qos.logback.classic;bundle-version="0.9.19",
+ ch.qos.logback.core;bundle-version="0.9.19",
+ org.slf4j.api;bundle-version="1.5.11"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/org.eclipse.m2e.logging/bin/org/eclipse/m2e/internal/logging/LogPlugin.class b/org.eclipse.m2e.logging/bin/org/eclipse/m2e/internal/logging/LogPlugin.class
new file mode 100644
index 00000000..05796582
--- /dev/null
+++ b/org.eclipse.m2e.logging/bin/org/eclipse/m2e/internal/logging/LogPlugin.class
Binary files differ
diff --git a/org.eclipse.m2e.logging/build.properties b/org.eclipse.m2e.logging/build.properties
new file mode 100644
index 00000000..371b1c8a
--- /dev/null
+++ b/org.eclipse.m2e.logging/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ defaultLogbackConfiguration/
diff --git a/org.eclipse.m2e.logging/defaultLogbackConfiguration/logback.xml b/org.eclipse.m2e.logging/defaultLogbackConfiguration/logback.xml
new file mode 100644
index 00000000..33746088
--- /dev/null
+++ b/org.eclipse.m2e.logging/defaultLogbackConfiguration/logback.xml
@@ -0,0 +1,29 @@
+<configuration scan="true">
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <layout class="ch.qos.logback.classic.PatternLayout">
+ <Pattern>%date [%thread] %-5level %logger{35} - %msg%n</Pattern>
+ </layout>
+ </appender>
+
+ <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <File>${org.maven.ide.eclipse.log.dir}/0.log</File>
+ <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <FileNamePattern>${org.maven.ide.eclipse.log.dir}/%i.log</FileNamePattern>
+ <MinIndex>1</MinIndex>
+ <MaxIndex>10</MaxIndex>
+ </rollingPolicy>
+ <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <MaxFileSize>100MB</MaxFileSize>
+ </triggeringPolicy>
+ <layout class="ch.qos.logback.classic.PatternLayout">
+ <Pattern>%date [%thread] %-5level %logger{35} - %msg%n</Pattern>
+ </layout>
+ </appender>
+
+ <root level="debug">
+ <appender-ref ref="FILE" />
+ <appender-ref ref="STDOUT" />
+ </root>
+
+ <logger name="org.eclipse.jetty.http.ssl" level="INFO" />
+</configuration>
diff --git a/org.eclipse.m2e.logging/src/org/eclipse/m2e/internal/logging/LogPlugin.java b/org.eclipse.m2e.logging/src/org/eclipse/m2e/internal/logging/LogPlugin.java
new file mode 100644
index 00000000..879594d0
--- /dev/null
+++ b/org.eclipse.m2e.logging/src/org/eclipse/m2e/internal/logging/LogPlugin.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.internal.logging;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.osgi.framework.BundleContext;
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.joran.JoranConfigurator;
+import ch.qos.logback.classic.util.ContextInitializer;
+import ch.qos.logback.core.joran.spi.JoranException;
+import ch.qos.logback.core.util.StatusPrinter;
+
+public class LogPlugin extends Plugin {
+
+ private static final String ID = "org.eclipse.m2e.logging";
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+
+ configureLogger(context);
+ }
+
+ private void configureLogger(BundleContext context) {
+ if (System.getProperty(ContextInitializer.CONFIG_FILE_PROPERTY) != null) {
+ return;
+ }
+
+ File stateDir = getStateLocation().toFile();
+
+ File configFile = new File(stateDir, "logback.xml");
+
+ if (!configFile.isFile()) {
+ //Copy the config file
+ try {
+ InputStream is = context.getBundle().getEntry("defaultLogbackConfiguration/logback.xml").openStream();
+ try {
+ configFile.getParentFile().mkdirs();
+ FileOutputStream fos = new FileOutputStream(configFile);
+ try {
+ for (byte[] buffer = new byte[1024 * 4];;) {
+ int n = is.read(buffer);
+ if (n < 0) {
+ break;
+ }
+ fos.write(buffer, 0, n);
+ }
+ } finally {
+ fos.close();
+ }
+ } finally {
+ is.close();
+ }
+
+ loadConfiguration(configFile.toURL());
+ } catch (Exception e) {
+ getLog().log( new Status(IStatus.WARNING, ID, "Exception while setting up logging.", e));
+ return;
+ }
+ }
+ }
+
+ private void loadConfiguration(URL configFile) throws JoranException {
+ LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+ lc.reset();
+
+ JoranConfigurator configurator = new JoranConfigurator();
+ configurator.setContext(lc);
+ configurator.doConfigure(configFile);
+
+ StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ }
+
+}

Back to the top