cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache CXF Documentation > LogBrowser - Configuration
Date Wed, 12 Dec 2012 16:58:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CXF20DOC&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CXF20DOC/LogBrowser+-+Configuration">LogBrowser
- Configuration</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~coheigea@apache.org">Colm
O hEigeartaigh</a>
    </h4>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-unchanged" >h1. LogBrowser <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >*This feature is available <span
class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">in
2.3-SNAPSHOT</span> <span class="diff-added-words"style="background-color: #dfd;">from
2.3.0</span> only, as part of the cxf-rt-management-web component* <br></td></tr>
            <tr><td class="diff-unchanged" > <br>LogBrowser is log entries
viewer. It is rich internet application which can be embedded in your web application. Configure
what log entries you would like to see and view them in your favorite browser. Anytime, anywhere
without using console. Let&#39;s make brief overview how to configure LogBrowser inside
your application. <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="LogBrowser-Configuration-LogBrowser"></a>LogBrowser</h1>

<p><b>This feature is available from 2.3.0 only, as part of the cxf-rt-management-web
component</b></p>

<p>LogBrowser is log entries viewer. It is rich internet application which can be embedded
in your web application. Configure what log entries you would like to see and view them in
your favorite browser. Anytime, anywhere without using console. Let's make brief overview
how to configure LogBrowser inside your application.</p>

<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/check.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td><b>Documentation</b><br
/>For more information about LogBrowser go to <a href="/confluence/display/CXF20DOC/LogBrowser+-+Software+Requirements+Specification"
title="LogBrowser - Software Requirements Specification">software requirements specification
(SRS)</a> or <a href="/confluence/display/CXF20DOC/LogBrowser+-+System+architectural+design"
title="LogBrowser - System architectural design">system architectural design (SAD)</a>
documents.</td></tr></table></div>

<h2><a name="LogBrowser-Configuration-Screenshots"></a>Screenshots</h2>

<p><span class="image-wrap" style=""><a class="confluence-thumbnail-link 1680x518"
href='https://cwiki.apache.org/confluence/download/attachments/23336032/accessControl.png'><img
src="/confluence/download/thumbnails/23336032/accessControl.png" style="border: 1px solid
black" /></a></span> <span class="image-wrap" style=""><a class="confluence-thumbnail-link
1680x518" href='https://cwiki.apache.org/confluence/download/attachments/23336032/accessControl-wrongUsernameOrPassword.png'><img
src="/confluence/download/thumbnails/23336032/accessControl-wrongUsernameOrPassword.png" style="border:
1px solid black" /></a></span> <span class="image-wrap" style=""><a
class="confluence-thumbnail-link 1680x803" href='https://cwiki.apache.org/confluence/download/attachments/23336032/browser.png'><img
src="/confluence/download/thumbnails/23336032/browser.png" style="border: 1px solid black"
/></a></span> <span class="image-wrap" style=""><a class="confluence-thumbnail-link
1680x803" href='https://cwiki.apache.org/confluence/download/attachments/23336032/settings.png'><img
src="/confluence/download/thumbnails/23336032/settings.png" style="border: 1px solid black"
/></a></span> <span class="image-wrap" style=""><a class="confluence-thumbnail-link
1680x803" href='https://cwiki.apache.org/confluence/download/attachments/23336032/settings-addEndpoint.png'><img
src="/confluence/download/thumbnails/23336032/settings-addEndpoint.png" style="border: 1px
solid black" /></a></span> <span class="image-wrap" style=""><a class="confluence-thumbnail-link
1680x803" href='https://cwiki.apache.org/confluence/download/attachments/23336032/settings-addEndpoint-emptyFields.png'><img
src="/confluence/download/thumbnails/23336032/settings-addEndpoint-emptyFields.png" style="border:
1px solid black" /></a></span></p>

<h2><a name="LogBrowser-Configuration-ConfiguringLogBrowserapplicationincontainerwithoutSpring"></a>Configuring
LogBrowser application in container without Spring</h2>

<h5><a name="LogBrowser-Configuration-Step1"></a>Step 1</h5>

<p>Add <tt>cxf-rt-management-web</tt> dependency to your Maven project (if
you don't use Maven as management tool, omit this step and add <tt>cxf-rt-management-web</tt>
library manually):</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>pom.xml</b></div><div class="codeContent
panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;project&gt;</span>

    [...]

    <span class="code-tag">&lt;dependencies&gt;</span>

        [...]

        <span class="code-tag">&lt;dependency&gt;</span>
            <span class="code-tag">&lt;groupId&gt;</span>org.apache.cxf<span
class="code-tag">&lt;/groupId&gt;</span>
            <span class="code-tag">&lt;artifactId&gt;</span>cxf-rt-management-web<span
class="code-tag">&lt;/artifactId&gt;</span>
            <span class="code-tag">&lt;version&gt;</span>2.3.0<span
class="code-tag">&lt;/version&gt;</span>
        <span class="code-tag">&lt;/dependency&gt;</span>

        [...]

    <span class="code-tag">&lt;/dependencies&gt;</span>

    [...]

<span class="code-tag">&lt;/project&gt;</span>
</pre>
</div></div>

<h5><a name="LogBrowser-Configuration-Step2"></a>Step 2</h5>

<p>Add new class to your project, <tt>LogBrowserApp</tt>. Add content from
sample below.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>LogBrowserApp.java</b></div><div
class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">package</span> yourpackage;

<span class="code-keyword">import</span> java.util.Collections;
<span class="code-keyword">import</span> java.util.HashMap;
<span class="code-keyword">import</span> java.util.HashSet;
<span class="code-keyword">import</span> java.util.Set;
<span class="code-keyword">import</span> javax.ws.rs.core.Application;
<span class="code-keyword">import</span> javax.ws.rs.ext.Provider;

<span class="code-keyword">import</span> org.apache.cxf.jaxrs.provider.AtomEntryProvider;
<span class="code-keyword">import</span> org.apache.cxf.jaxrs.provider.AtomFeedProvider;
<span class="code-keyword">import</span> org.apache.cxf.management.web.logging.atom.AtomPullServer;
<span class="code-keyword">import</span> org.apache.cxf.management.web.logging.logbrowser.bootstrapping.BootstrapStorage;
<span class="code-keyword">import</span> org.apache.cxf.management.web.logging.logbrowser.bootstrapping.SimpleAuthenticationFilter;
<span class="code-keyword">import</span> org.apache.cxf.management.web.logging.logbrowser.bootstrapping.SimpleXMLSettingsStorage;

@Provider
<span class="code-keyword">public</span> class LogBrowserApp <span class="code-keyword">extends</span>
Application {
	Set&lt;<span class="code-object">Object</span>&gt; classes = <span
class="code-keyword">new</span> HashSet&lt;<span class="code-object">Object</span>&gt;();
	
	<span class="code-keyword">static</span> {
        AtomPullServer aps = <span class="code-keyword">new</span> AtomPullServer();
        aps.setLoggers(<span class="code-quote">"yourpackage:INFO"</span>);
        aps.init();

        classes.add(aps);
        classes.add(<span class="code-keyword">new</span> AtomFeedProvider());
        classes.add(<span class="code-keyword">new</span> AtomEntryProvider());
        classes.add(<span class="code-keyword">new</span> BootstrapStorage(<span
class="code-keyword">new</span> SimpleXMLSettingsStorage()));
        classes.add(<span class="code-keyword">new</span> SimpleAuthenticationFilter(<span
class="code-keyword">new</span> HashMap&lt;<span class="code-object">String</span>,
<span class="code-object">String</span>&gt;() {
            {
            	<span class="code-comment">// add all required users by specified username
and password, <span class="code-keyword">for</span> example: put(<span class="code-quote">"admin"</span>,
<span class="code-quote">"admin"</span>);
</span>            }
        }));
        classes.add(<span class="code-keyword">new</span> BootstrapStorage.StaticFileProvider());
        classes.add(<span class="code-keyword">new</span> BootstrapStorage.SettingsProvider());
	}
	
    @Override
    <span class="code-keyword">public</span> Set&lt;<span class="code-object">Class</span>&lt;?&gt;&gt;
getClasses() {
        <span class="code-keyword">return</span> Collections.emptySet();
    }

    @Override
    <span class="code-keyword">public</span> Set&lt;<span class="code-object">Object</span>&gt;
getSingletons() {
        <span class="code-keyword">return</span> classes;
    }
}
</pre>
</div></div>

<p>We have to modify newly created class a little bit:</p>
<ul>
	<li>Go to line 1. Replace <tt>yourpackage</tt> phrase with a valid package.</li>
	<li>Go to line 23. Configure which log entries should be caught. If you would like
to catch all log entries related with your application at the INFO level, simply replace <tt>yourpackage</tt>
phrase with your application's package. For more information how to configure custom loggers
go to <a href="/confluence/display/CXF20DOC/JAX-RS" title="JAX-RS">AtomPullServer description</a>.</li>
	<li>Go to line 32. Add all required users. Keep in mind that each user has his own
independent configuration.</li>
</ul>


<h5><a name="LogBrowser-Configuration-Step3"></a>Step 3</h5>

<p>Add new servlet definition to your <tt>web.xml</tt> file, like in sample
below: </p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>web.xml</b></div><div class="codeContent
panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;web-app&gt;</span>

	[...]
	
	<span class="code-tag">&lt;servlet&gt;</span>
		<span class="code-tag">&lt;servlet-name&gt;</span>LogBrowserApp<span
class="code-tag">&lt;/servlet-name&gt;</span>
		<span class="code-tag">&lt;display-name&gt;</span>LogBrowserApp<span
class="code-tag">&lt;/display-name&gt;</span>
		<span class="code-tag">&lt;servlet-class&gt;</span>
			org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet
		<span class="code-tag">&lt;/servlet-class&gt;</span>
		<span class="code-tag">&lt;init-param&gt;</span>
			<span class="code-tag">&lt;param-name&gt;</span>javax.ws.rs.Application<span
class="code-tag">&lt;/param-name&gt;</span>
			<span class="code-tag">&lt;param-value&gt;</span>yourpackage.LogBrowserApp<span
class="code-tag">&lt;/param-value&gt;</span>
		<span class="code-tag">&lt;/init-param&gt;</span>
		<span class="code-tag">&lt;load-on-startup&gt;</span>1<span class="code-tag">&lt;/load-on-startup&gt;</span>
	<span class="code-tag">&lt;/servlet&gt;</span>

	<span class="code-tag">&lt;servlet-mapping&gt;</span>
		<span class="code-tag">&lt;servlet-name&gt;</span>LogBrowserApp<span
class="code-tag">&lt;/servlet-name&gt;</span>
		<span class="code-tag">&lt;url-pattern&gt;</span>/log/*<span class="code-tag">&lt;/url-pattern&gt;</span>
	<span class="code-tag">&lt;/servlet-mapping&gt;</span>
	
	[...]

<span class="code-tag">&lt;/web-app&gt;</span>	
</pre>
</div></div>

<p>Go to line 13 and replace <tt>yourpackage</tt> phrase with a valid package.</p>

<h5><a name="LogBrowser-Configuration-Step4"></a>Step 4</h5>

<p>Rebuild and run your application.</p>

<h5><a name="LogBrowser-Configuration-Step5"></a>Step 5</h5>

<p>Open browser and go to URL: </p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-none">http://localhost:9002/log/bootstrapstorage/resources/LogBrowser.html</pre>
</div></div>

<h5><a name="LogBrowser-Configuration-Step6"></a>Step 6</h5>

<p>Add new endpoint with URL: </p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-none">http://localhost:9002/log/logs</pre>
</div></div>

<p>Congratulation. Now you can easily view log enties using LogBrowser. </p>

<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/check.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td><b>Complete sample</b><br
/>For more details about configuration go to <a href="https://svn.apache.org/repos/asf/cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/"
class="external-link" rel="nofollow">sample project</a>.</td></tr></table></div>


    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/LogBrowser+-+Configuration">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=23336032&revisedVersion=5&originalVersion=4">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/LogBrowser+-+Configuration?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message