Index: parent/pom.xml
===================================================================
--- parent/pom.xml	(revision 772537)
+++ parent/pom.xml	(working copy)
@@ -179,6 +179,11 @@
         <version>2.5.6</version>
       </dependency>
       <dependency>
+      <groupId>org.springframework</groupId>
+        <artifactId>spring-jmx</artifactId>
+        <version>2.0.8</version>
+      </dependency>
+      <dependency>
         <groupId>org.aspectj</groupId>
         <artifactId>aspectjrt</artifactId>
         <version>1.6.1</version>
Index: pom.xml
===================================================================
--- pom.xml	(revision 772537)
+++ pom.xml	(working copy)
@@ -39,6 +39,7 @@
     <module>cocoon-sitemap</module>
     <module>cocoon-stax</module>
     <module>cocoon-stringtemplate</module>
+    <module>cocoon-monitoring</module>
     <module>parent</module>
     <module>cocoon-sax</module>
   </modules>
Index: cocoon-monitoring/src/main/java/org/apache/cocoon/monitoring/RestoreLoggingConfiguration.java
===================================================================
--- cocoon-monitoring/src/main/java/org/apache/cocoon/monitoring/RestoreLoggingConfiguration.java	(revision 0)
+++ cocoon-monitoring/src/main/java/org/apache/cocoon/monitoring/RestoreLoggingConfiguration.java	(revision 0)
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.monitoring;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
+public class RestoreLoggingConfiguration {
+
+    private long delay;
+    private Logger logger;
+    private Level oldLevel;
+
+    public RestoreLoggingConfiguration(final Logger logger, final Level oldLevel,
+            String timeout) {
+
+        this.logger = logger;
+        this.oldLevel = oldLevel;
+
+        long factor;
+        char unit = timeout.charAt(timeout.length() - 1); // get last char, it should be our unit
+        switch (unit) {
+        case 'm': // minute
+            factor = 60 * 1000;
+            break;
+        case 'h': // hour
+            factor = 60 * 60 * 1000;
+            break;
+        case 'd': // day
+            factor = 24 * 60 * 60 * 1000;
+            break;
+        default:
+            throw new UnsupportedOperationException("Unsupporterd unit: " + unit);
+        }
+
+        float multipler = Float.parseFloat(timeout.substring(0, timeout.length() - 1));
+        delay = Math.round(multipler * factor);
+
+    }
+
+    public void start() {
+        TimerTask task = new TimerTask() {
+            @Override
+            public void run() {
+                logger.setLevel(oldLevel);
+            }
+
+            @Override
+            public boolean cancel() {
+                run(); // set old level on task cancel
+                return super.cancel();
+            }
+        };
+
+        Timer timer = new Timer("Restore " + logger.getName() + " to level" + oldLevel, true);
+        timer.schedule(task, delay);
+    }
+
+}
Index: cocoon-monitoring/src/main/java/org/apache/cocoon/monitoring/Log4JReconfigure.java
===================================================================
--- cocoon-monitoring/src/main/java/org/apache/cocoon/monitoring/Log4JReconfigure.java	(revision 0)
+++ cocoon-monitoring/src/main/java/org/apache/cocoon/monitoring/Log4JReconfigure.java	(revision 0)
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.monitoring;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.apache.log4j.spi.LoggerRepository;
+import org.springframework.jmx.export.annotation.ManagedAttribute;
+import org.springframework.jmx.export.annotation.ManagedOperation;
+import org.springframework.jmx.export.annotation.ManagedOperationParameter;
+import org.springframework.jmx.export.annotation.ManagedOperationParameters;
+import org.springframework.jmx.export.annotation.ManagedResource;
+
+@ManagedResource
+public class Log4JReconfigure {
+
+    private LoggerRepository logRepo;
+
+    public Log4JReconfigure() {
+        logRepo = LogManager.getLoggerRepository();
+    }
+
+    @ManagedAttribute(description="Return list of all configured loggers with they level.")
+    public String[] getLoggers() {
+        List<String> result = new ArrayList<String>();
+        @SuppressWarnings("unchecked")
+        Enumeration<Logger> currentLoggers = logRepo.getCurrentLoggers();
+        while (currentLoggers.hasMoreElements()) {
+            Logger tmpLogger = currentLoggers.nextElement();
+            if (tmpLogger.getLevel() != null) {
+                result.add(tmpLogger.getName() + ": " + tmpLogger.getLevel());
+            }
+        }
+        return result.toArray(new String[] {});
+    }
+
+    @ManagedOperation(description="Sets logging level for paticular package or class. Returns true if operation was succesful.")
+    @ManagedOperationParameters(value= {
+            @ManagedOperationParameter(name="packageOrClassName", description="Name of package or class that logging level should be changed."),
+            @ManagedOperationParameter(name="newLevel", description="New logging level for that package/class. Avaliable log levels are: OFF, INFO, WARN, ERROR, FATAL, TRACE, DEBUG, ALL")
+    })
+    public boolean setLoggingLevel(String  packageOrClassName, String newLevel) {
+        boolean result = false;
+        Logger logger = logRepo.getLogger(packageOrClassName);
+        if (logger != null) {
+            logger.setLevel(Level.toLevel(newLevel.toUpperCase()));
+            result = true;
+        }
+        return result;
+    }
+
+    @ManagedOperation(description="Sets new logging level for amout of time. After timeout log level is set back to old value.")
+    @ManagedOperationParameters(value={
+            @ManagedOperationParameter(name="packageOrClassName", description="Name of package or class that logging level should be changed."),
+            @ManagedOperationParameter(name="temporalLevel", description="Temporal log level that should be set for specified amout of time."),
+            @ManagedOperationParameter(name="timeOut", description="Amount of time that temporalLevel should be active. Value of timeOut should match regex: ^[0-9.]+[dhm]?$ where 'd' means day, 'h' hours and 'm' minutes")
+    })
+    public boolean setLoggingTempoporalLevel(String packageOrClassName, String temporalLevel, String timeOut) {
+        if (!timeOut.matches("^[0-9.]+[dhm]?$")) {
+            throw new UnsupportedOperationException("Unsupported time out format: " + timeOut);
+        }
+        boolean result = false;
+        Logger logger = logRepo.getLogger(packageOrClassName);
+        if (logger != null) {
+            Level oldLevel = logger.getLevel();
+            RestoreLoggingConfiguration restoreThread = new RestoreLoggingConfiguration(logger, oldLevel, timeOut.toLowerCase());
+            logger.setLevel(Level.toLevel(temporalLevel));
+            restoreThread.start();
+            result = true;
+        }
+        return result;
+    }
+
+}
Index: cocoon-monitoring/src/main/resources/META-INF/cocoon/spring/cocoon-monitoring.xml
===================================================================
--- cocoon-monitoring/src/main/resources/META-INF/cocoon/spring/cocoon-monitoring.xml	(revision 0)
+++ cocoon-monitoring/src/main/resources/META-INF/cocoon/spring/cocoon-monitoring.xml	(revision 0)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements. See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to you under the Apache License, Version
+    2.0 (the "License"); you may not use this file except in compliance
+    with the License. You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+    applicable law or agreed to in writing, software distributed under
+    the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
+    OR CONDITIONS OF ANY KIND, either express or implied. See the
+    License for the specific language governing permissions and
+    limitations und
+  -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+  <bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
+    <property name="assembler" ref="assembler" />
+    <property name="namingStrategy" ref="namingStrategy" />
+    <property name="autodetect" value="true" />
+  </bean>
+
+  <bean id="jmxAttributeSource"
+    class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource" />
+
+  <bean id="assembler"
+    class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler">
+    <property name="attributeSource" ref="jmxAttributeSource" />
+  </bean>
+
+  <bean id="namingStrategy"
+    class="org.springframework.jmx.export.naming.MetadataNamingStrategy">
+    <property name="attributeSource" ref="jmxAttributeSource" />
+  </bean>
+  <bean class="org.apache.cocoon.monitoring.Log4JReconfigure"
+    scope="singleton" />
+</beans>
\ No newline at end of file
