| <?xml version="1.0" encoding="ISO-8859-1" ?> |
| <!-- |
| ~ 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. |
| --> |
| |
| <document> |
| <properties> |
| <title>Apache Synapse - Sample 601</title> |
| </properties> |
| <body> |
| <section name="Sample 601: Using Synapse Observers"> |
| <subsection name="Objective"> |
| <p> |
| Demonstrate the ability to monitor the Synapse configuration at runtime using the |
| SynapseObserver interface |
| </p> |
| </subsection> |
| <subsection name="Running the Sample"> |
| <p> |
| Open the synapse.properties file in the SYNAPSE_HOME/repository/conf directory |
| using a text editor and uncomment the line which defines the simple logging |
| Synapse observer. |
| </p> |
| <div class="consoleOutput">synapse.observers=samples.userguide.SimpleLoggingObserver</div> |
| <p> |
| Open the log4j.properties file in the SYNAPSE_HOME/lib directory and |
| uncomment the line which sets the INFO log level to the samples.userguide |
| package. |
| </p> |
| <div class="consoleOutput">log4j.category.samples.userguide=INFO</div> |
| <p> |
| Start Synapse using any of the sample configurations. The SimpleLoggingObserver |
| will capture events that occur while constructing the Synapse configuration |
| and log them on the console as follows. |
| </p> |
| <div class="consoleOutput">2009-08-06 14:30:24,578 [-] [main] INFO SimpleLoggingObserver Simple logging observer initialized...Capturing Synapse events... |
| 2009-08-06 14:30:24,604 [-] [main] INFO SimpleLoggingObserver Endpoint : a3 was added to the Synapse configuration successfully |
| 2009-08-06 14:30:24,605 [-] [main] INFO SimpleLoggingObserver Endpoint : a2 was added to the Synapse configuration successfully |
| 2009-08-06 14:30:24,606 [-] [main] INFO SimpleLoggingObserver Endpoint : null was added to the Synapse configuration successfully |
| 2009-08-06 14:30:24,611 [-] [main] INFO SimpleLoggingObserver Local entry : a1 was added to the Synapse configuration successfully |
| 2009-08-06 14:30:24,649 [-] [main] INFO SimpleLoggingObserver Proxy service : StockQuoteProxy2 was added to the Synapse configuration successfully |
| 2009-08-06 14:30:24,661 [-] [main] INFO SimpleLoggingObserver Proxy service : StockQuoteProxy1 was added to the Synapse configuration successfully |
| 2009-08-06 14:30:24,664 [-] [main] INFO SimpleLoggingObserver Sequence : main was added to the Synapse configuration successfully |
| 2009-08-06 14:30:24,701 [-] [main] INFO SimpleLoggingObserver Sequence : fault was added to the Synapse configuration successfully</div> |
| <p> |
| The SimpleLoggingObserver is implemented as follows. It does not override any of the event handler implementations |
| in the AbstractSynapseObserver class. The AbstractSynapseObserver logs all the received events by default. |
| </p> |
| <div class="consoleOutput">package samples.userguide; |
| |
| import org.apache.synapse.config.AbstractSynapseObserver; |
| |
| public class SimpleLoggingObserver extends AbstractSynapseObserver { |
| |
| public SimpleLoggingObserver() { |
| super(); |
| log.info("Simple logging observer initialized...Capturing Synapse events..."); |
| } |
| }</div> |
| </subsection> |
| </section> |
| <p><a href="../samples.html">Back to Catalog</a></p> |
| </body> |
| </document> |