You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by jo...@apache.org on 2007/11/08 19:36:13 UTC

svn commit: r593246 - in /maven/archiva/trunk: archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/ archiva-web/archiva-webapp/ archiva-web/archiva-webapp/src/appserver-base/conf/ archiva-web/archiva-webapp/src...

Author: joakime
Date: Thu Nov  8 10:36:12 2007
New Revision: 593246

URL: http://svn.apache.org/viewvc?rev=593246&view=rev
Log:
[MRM-564] Audit log is not populated when artifacts are deployed.
Expanded Audit concepts into listener / event / log.
Using log4j for audit log (for consistency with other logging)
Moved AuditLog from webapp to repository-layer.



Added:
    maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/
    maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditEvent.java   (with props)
    maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditListener.java   (with props)
    maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditLog.java   (with props)
    maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/Auditable.java   (with props)
Removed:
    maven/archiva/trunk/archiva-web/archiva-webapp/src/appserver-base/conf/archiva.xml
    maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/AuditLog.java
Modified:
    maven/archiva/trunk/archiva-web/archiva-webapp/pom.xml
    maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/ProxiedDavServer.java
    maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/RepositoryServlet.java
    maven/archiva/trunk/archiva-web/archiva-webapp/src/main/resources/log4j.xml

Added: maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditEvent.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditEvent.java?rev=593246&view=auto
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditEvent.java (added)
+++ maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditEvent.java Thu Nov  8 10:36:12 2007
@@ -0,0 +1,112 @@
+package org.apache.maven.archiva.repository.audit;
+
+/*
+ * 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.
+ */
+
+/**
+ * AuditEvent 
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class AuditEvent
+{
+    public static final String CREATE_DIR = "Created Directory";
+
+    public static final String CREATE_FILE = "Created File";
+
+    public static final String REMOVE_DIR = "Removed Directory";
+
+    public static final String REMOVE_FILE = "Removed File";
+
+    public static final String MODIFY_FILE = "Modify File";
+    
+    private String repositoryId;
+
+    private String userId;
+    
+    private String remoteIP;
+
+    private String resource;
+
+    private String action;
+
+    public AuditEvent()
+    {
+        /* do nothing */
+    }
+
+    public AuditEvent( String repoId, String user, String resource, String action )
+    {
+        this.repositoryId = repoId;
+        this.userId = user;
+        this.resource = resource;
+        this.action = action;
+    }
+
+    public String getRepositoryId()
+    {
+        return repositoryId;
+    }
+
+    public void setRepositoryId( String repositoryId )
+    {
+        this.repositoryId = repositoryId;
+    }
+
+    public String getUserId()
+    {
+        return userId;
+    }
+
+    public void setUserId( String userId )
+    {
+        this.userId = userId;
+    }
+
+    public String getResource()
+    {
+        return resource;
+    }
+
+    public void setResource( String resource )
+    {
+        this.resource = resource;
+    }
+
+    public String getAction()
+    {
+        return action;
+    }
+
+    public void setAction( String action )
+    {
+        this.action = action;
+    }
+
+    public String getRemoteIP()
+    {
+        return remoteIP;
+    }
+
+    public void setRemoteIP( String remoteIP )
+    {
+        this.remoteIP = remoteIP;
+    }
+}

Propchange: maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditEvent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditEvent.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Propchange: maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditEvent.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditListener.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditListener.java?rev=593246&view=auto
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditListener.java (added)
+++ maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditListener.java Thu Nov  8 10:36:12 2007
@@ -0,0 +1,36 @@
+package org.apache.maven.archiva.repository.audit;
+
+/*
+ * 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.
+ */
+
+/**
+ * AuditListener 
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public interface AuditListener
+{
+    /**
+     * Notification that an audit event occured. 
+     * 
+     * @param event the event details.
+     */
+    public void auditEvent( AuditEvent event );
+}

Propchange: maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditListener.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Propchange: maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditListener.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditLog.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditLog.java?rev=593246&view=auto
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditLog.java (added)
+++ maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditLog.java Thu Nov  8 10:36:12 2007
@@ -0,0 +1,56 @@
+package org.apache.maven.archiva.repository.audit;
+
+/*
+ * 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.
+ */
+
+import org.apache.log4j.Logger;
+
+/**
+ * AuditLog - Audit Log. 
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ * 
+ * @plexus.component role="org.apache.maven.archiva.repository.audit.AuditListener"
+ *                   role-hint="logging"
+ */
+public class AuditLog
+    implements AuditListener
+{
+    public static final Logger logger = Logger.getLogger( "org.apache.archiva.AuditLog" );
+    
+    private static final char DELIM = ' '; 
+
+    /**
+     * Creates a log message in the following format ...
+     * 
+     * "{repository_id} {user_id} {remote_ip} \"{resource}\" \"{action}\""
+     */
+    public void auditEvent( AuditEvent event )
+    {
+        StringBuffer msg = new StringBuffer();
+        msg.append( event.getRepositoryId() ).append( DELIM );
+        msg.append( event.getUserId() ).append( DELIM );
+        msg.append( event.getRemoteIP() ).append( DELIM );
+        msg.append( '\"' ).append( event.getResource() ).append( '\"' ).append( DELIM );
+        msg.append( '\"' ).append( event.getAction() ).append( '\"' );
+
+        logger.info( msg.toString() );
+    }
+}

Propchange: maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditLog.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditLog.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Propchange: maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditLog.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/Auditable.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/Auditable.java?rev=593246&view=auto
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/Auditable.java (added)
+++ maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/Auditable.java Thu Nov  8 10:36:12 2007
@@ -0,0 +1,48 @@
+package org.apache.maven.archiva.repository.audit;
+
+/*
+ * 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.
+ */
+
+/**
+ * Auditable 
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public interface Auditable
+{
+    /**
+     * Add an AuditListener.
+     * 
+     * @param the listener to add.
+     */
+    public void addAuditListener( AuditListener auditListener );
+
+    /**
+     * Remove an AuditListener.
+     * 
+     * @param the listener to remove.
+     */
+    public void removeAuditListener( AuditListener auditListener );
+
+    /**
+     * Remove all registered {@link AuditListener} objects.
+     */
+    public void clearAuditListeners();
+}

Propchange: maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/Auditable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/Auditable.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Propchange: maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/Auditable.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: maven/archiva/trunk/archiva-web/archiva-webapp/pom.xml
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/pom.xml?rev=593246&r1=593245&r2=593246&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-web/archiva-webapp/pom.xml (original)
+++ maven/archiva/trunk/archiva-web/archiva-webapp/pom.xml Thu Nov  8 10:36:12 2007
@@ -420,7 +420,6 @@
           </roleDefaults>
         </configuration>
       </plugin>
-      <!--
       <plugin>
         <artifactId>maven-antrun-plugin</artifactId>
         <executions>
@@ -439,7 +438,6 @@
           </execution>
         </executions>
       </plugin>
-       -->
     </plugins>
   </build>
   <profiles>

Modified: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/ProxiedDavServer.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/ProxiedDavServer.java?rev=593246&r1=593245&r2=593246&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/ProxiedDavServer.java (original)
+++ maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/ProxiedDavServer.java Thu Nov  8 10:36:12 2007
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.maven.archiva.common.utils.PathUtil;
 import org.apache.maven.archiva.model.ArtifactReference;
 import org.apache.maven.archiva.model.ProjectReference;
 import org.apache.maven.archiva.model.VersionedReference;
@@ -28,10 +29,14 @@
 import org.apache.maven.archiva.repository.RepositoryContentFactory;
 import org.apache.maven.archiva.repository.RepositoryException;
 import org.apache.maven.archiva.repository.RepositoryNotFoundException;
+import org.apache.maven.archiva.repository.audit.AuditEvent;
+import org.apache.maven.archiva.repository.audit.AuditListener;
+import org.apache.maven.archiva.repository.audit.Auditable;
 import org.apache.maven.archiva.repository.content.RepositoryRequest;
 import org.apache.maven.archiva.repository.layout.LayoutException;
 import org.apache.maven.archiva.repository.metadata.MetadataTools;
 import org.apache.maven.archiva.repository.metadata.RepositoryMetadataException;
+import org.apache.maven.archiva.security.ArchivaUser;
 import org.apache.maven.model.DistributionManagement;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.Relocation;
@@ -49,6 +54,8 @@
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
@@ -64,12 +71,18 @@
  */
 public class ProxiedDavServer
     extends AbstractDavServerComponent
+    implements Auditable
 {
     /**
      * @plexus.requirement role-hint="simple"
      */
     private DavServerComponent davServer;
-
+    
+    /**
+     * @plexus.requirement role="org.apache.maven.archiva.repository.audit.AuditListener"
+     */
+    private List<AuditListener> auditListeners = new ArrayList<AuditListener>();
+    
     /**
      * @plexus.requirement
      */
@@ -89,6 +102,11 @@
      * @plexus.requirement
      */
     private MetadataTools metadataTools;
+    
+    /**
+     * @plexus.requirement role-hint="xwork"
+     */
+    private ArchivaUser archivaUser;
 
     private ManagedRepositoryContent managedRepository;
 
@@ -136,11 +154,11 @@
     {
         boolean isGet = WebdavMethodUtil.isReadMethod( request.getRequest().getMethod() );
         boolean isPut = WebdavMethodUtil.isWriteMethod( request.getRequest().getMethod() );
+        String resource = request.getLogicalResource();
         
         if ( isGet )
         {
             // Default behaviour is to treat the resource natively.
-            String resource = request.getLogicalResource();
             File resourceFile = new File( managedRepository.getRepoRoot(), resource );
 
             // If this a directory resource, then we are likely browsing.
@@ -173,8 +191,13 @@
                 // Adjust the pathInfo resource to be in the format that the dav server impl expects.
                 request.getRequest().setPathInfo( resource );
 
+                boolean previouslyExisted = resourceFile.exists();
+                
                 // Attempt to fetch the resource from any defined proxy.
-                fetchContentFromProxies( request, resource );
+                if( fetchContentFromProxies( request, resource ) )
+                {
+                    processAuditEvents( request, resource, previouslyExisted, resourceFile, " (proxied)" );
+                }
             }
             catch ( LayoutException e )
             {
@@ -217,12 +240,24 @@
             File rootDirectory = getRootDirectory();
             if ( rootDirectory != null )
             {
-                new File( rootDirectory, request.getLogicalResource() ).getParentFile().mkdirs();
+                File destDir = new File( rootDirectory, resource ).getParentFile();
+                if( !destDir.exists() )
+                {
+                    destDir.mkdirs();
+                    String relPath = PathUtil.getRelative( rootDirectory.getAbsolutePath(), destDir );
+                    triggerAuditEvent( request, relPath, AuditEvent.CREATE_DIR );
+                }
             }
             
+            File resourceFile = new File( managedRepository.getRepoRoot(), resource );
+            
+            boolean previouslyExisted = resourceFile.exists();
+            
             // Allow the dav server to process the put request.
             davServer.process( request, response );
             
+            processAuditEvents( request, resource, previouslyExisted, resourceFile, null );
+            
             // All done.
             return;
         }
@@ -277,7 +312,7 @@
         }
     }
 
-    private void fetchContentFromProxies( DavServerRequest request, String resource )
+    private boolean fetchContentFromProxies( DavServerRequest request, String resource )
         throws ServletException
     {
         if ( repositoryRequest.isSupportFile( resource ) )
@@ -285,16 +320,13 @@
             // Checksums are fetched with artifact / metadata.
             
             // Need to adjust the path for the checksum resource.
-            return;
+            return false;
         }
 
         // Is it a Metadata resource?
         if ( repositoryRequest.isDefault( resource ) && repositoryRequest.isMetadata( resource ) )
         {
-            if ( fetchMetadataFromProxies( request, resource ) )
-            {
-                return;
-            }
+            return fetchMetadataFromProxies( request, resource );
         }
 
         // Not any of the above? Then it's gotta be an artifact reference.
@@ -307,11 +339,11 @@
             {
                 applyServerSideRelocation( artifact );
 
-                connectors.fetchFromProxies( managedRepository, artifact );
+                File proxiedFile = connectors.fetchFromProxies( managedRepository, artifact );
                 
                 // Set the path to the resource using managed repository specific layout format.
                 request.getRequest().setPathInfo( managedRepository.toPath( artifact ) );
-                return;
+                return ( proxiedFile != null );
             }
         }
         catch ( LayoutException e )
@@ -322,6 +354,7 @@
         {
             throw new ServletException( "Unable to fetch artifact resource.", e );
         }
+        return false;
     }
 
     private boolean fetchMetadataFromProxies( DavServerRequest request, String resource )
@@ -480,5 +513,83 @@
     public ManagedRepositoryContent getRepository()
     {
         return managedRepository;
+    }
+    
+    private void processAuditEvents( DavServerRequest request, String resource, boolean previouslyExisted,
+                                     File resourceFile, String suffix )
+    {
+        if( suffix == null )
+        {
+            suffix = "";
+        }
+        
+        // Process Create Audit Events.
+        if ( !previouslyExisted && resourceFile.exists() )
+        {
+            if ( resourceFile.isFile() )
+            {
+                triggerAuditEvent( request, resource, AuditEvent.CREATE_FILE + suffix );
+            }
+            else if ( resourceFile.isDirectory() )
+            {
+                triggerAuditEvent( request, resource, AuditEvent.CREATE_DIR + suffix );
+            }
+        }
+        // Process Remove Audit Events.
+        else if ( previouslyExisted && !resourceFile.exists() )
+        {
+            if ( resourceFile.isFile() )
+            {
+                triggerAuditEvent( request, resource, AuditEvent.REMOVE_FILE + suffix );
+            }
+            else if ( resourceFile.isDirectory() )
+            {
+                triggerAuditEvent( request, resource, AuditEvent.REMOVE_DIR + suffix );
+            }
+        }
+        // Process modify events.
+        else
+        {
+            if ( resourceFile.isFile() )
+            {
+                triggerAuditEvent( request, resource, AuditEvent.MODIFY_FILE + suffix );
+            }
+        }
+    }
+    
+    private void triggerAuditEvent( String user, String remoteIP, String resource, String action )
+    {
+        AuditEvent event = new AuditEvent( this.getPrefix(), user, resource, action );
+        event.setRemoteIP( remoteIP );
+
+        for ( AuditListener listener : auditListeners )
+        {
+            listener.auditEvent( event );
+        }
+    }
+
+    private void triggerAuditEvent( DavServerRequest request, String resource, String action )
+    {
+        triggerAuditEvent( archivaUser.getActivePrincipal(), getRemoteIP( request ), resource, action );
+    }
+
+    private String getRemoteIP( DavServerRequest request )
+    {
+        return request.getRequest().getRemoteAddr();
+    }
+
+    public void addAuditListener( AuditListener listener )
+    {
+        this.auditListeners.add( listener );
+    }
+
+    public void clearAuditListeners()
+    {
+        this.auditListeners.clear();
+    }
+
+    public void removeAuditListener( AuditListener listener )
+    {
+        this.auditListeners.remove( listener );
     }
 }

Modified: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/RepositoryServlet.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/RepositoryServlet.java?rev=593246&r1=593245&r2=593246&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/RepositoryServlet.java (original)
+++ maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/RepositoryServlet.java Thu Nov  8 10:36:12 2007
@@ -63,8 +63,6 @@
 
     private HttpAuthenticator httpAuth;
 
-    private AuditLog audit;
-
     private ArchivaConfiguration configuration;
 
     private Map<String, ManagedRepositoryConfiguration> repositoryMap;
@@ -80,7 +78,6 @@
         
         securitySystem = (SecuritySystem) lookup( SecuritySystem.ROLE );
         httpAuth = (HttpAuthenticator) lookup( HttpAuthenticator.ROLE, "basic" );
-        audit = (AuditLog) lookup( AuditLog.ROLE );
 
         configuration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName() );
         configuration.addListener( this );
@@ -108,7 +105,6 @@
             DavServerComponent server = createServer( repo.getId(), repoDir, servletConfig );
 
             server.setUseIndexHtml( true );
-            server.addListener( audit );
         }
     }
     
@@ -130,14 +126,6 @@
         catch ( ServletException e )
         {
             log( "Unable to release HttpAuth : " + e.getMessage(), e );
-        }
-        try
-        {
-            release( audit );
-        }
-        catch ( ServletException e )
-        {
-            log( "Unable to release AuditLog : " + e.getMessage(), e );
         }
         try
         {

Modified: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/resources/log4j.xml
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/main/resources/log4j.xml?rev=593246&r1=593245&r2=593246&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-web/archiva-webapp/src/main/resources/log4j.xml (original)
+++ maven/archiva/trunk/archiva-web/archiva-webapp/src/main/resources/log4j.xml Thu Nov  8 10:36:12 2007
@@ -11,6 +11,15 @@
       <param name="ConversionPattern" value="%-4r [%t] %-5p %c %x - %m%n"/>
     </layout>
   </appender>
+  
+  <appender name="auditlog" class="org.apache.log4j.DailyRollingFileAppender">
+    <param name="file" value="${appserver.base}/logs/audit.log" />
+    <param name="append" value="true" />
+    <param name="datePattern" value="'.'yyyy-MM-dd" />
+    <layout class="org.apache.log4j.PatternLayout">
+      <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %m%n"/>
+    </layout>
+  </appender>
 
   <appender name="console" class="org.apache.log4j.ConsoleAppender">
     <param name="Target" value="System.out"/>
@@ -28,6 +37,11 @@
     <level value="debug" />
   </logger>
 
+  <logger name="org.apache.archiva.AuditLog">
+    <level value="info" />
+    <appender-ref ref="auditlog" />
+  </logger>
+  
   <logger name="org.codehaus.plexus.security">
     <level value="info"/>
   </logger>