forked from avelinsk/nexus-google-analytics-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* modified logback.xml to use of LoggingConverter
- Loading branch information
Daniel Zabel
committed
Apr 17, 2013
1 parent
b4c6d0e
commit dff5248
Showing
2 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/main/java/com/coremedia/nexus/plugins/LoggingConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.coremedia.nexus.plugins; | ||
|
||
|
||
import ch.qos.logback.classic.pattern.ClassicConverter; | ||
import ch.qos.logback.classic.spi.ILoggingEvent; | ||
import org.apache.shiro.subject.Subject; | ||
import org.codehaus.plexus.component.annotations.Requirement; | ||
import org.sonatype.security.SecuritySystem; | ||
|
||
public class LoggingConverter extends ClassicConverter { | ||
|
||
@Requirement | ||
private SecuritySystem securitySystem; | ||
|
||
@Override | ||
public String convert(ILoggingEvent event) { | ||
String userName = "anonymous"; | ||
|
||
if (securitySystem != null) { | ||
final Subject subject = securitySystem.getSubject(); | ||
if (subject != null) { | ||
userName = subject.getPrincipal().toString(); | ||
} | ||
} | ||
return userName; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters