Dans mon module Web dans les ressources que j'avoir ce fichier log4j2.xml
:Pourquoi je reçois Erreur lors du traitement de l'élément AUDIT pour log4j2 dans le projet java ee?
<?xml version="1.0" encoding="UTF-8"?>
<Configuration strict="true" name="XMLConfigTest" status="debug" verbose="true"
packages="hu.pannonris.if3.web.util.appender" monitorInterval="1">
<Properties>
<Property name="pattern">%d | %X{session_id} | %X{tranz_id} | %p | [%t] %l | %m%n</Property>
</Properties>
<Appenders>
<File name="FILE" fileName="logfile.log" append="true">
<PatternLayout pattern="${pattern}"/>
<Filters>
<MarkerFilter marker="SQL_QUERY" onMatch="DENY" onMismatch="NEUTRAL"/>
<MarkerFilter marker="PUT_USER_MARKER" onMatch="DENY" onMismatch="NEUTRAL"/>
<MarkerFilter marker="GET_USER_MARKER" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="SQL_UPDATE_FULL" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="SQL_UPDATE" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="SQL_QUERY_LIST" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="SQL_DELETE" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="SQL_CREATE" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="SYSTEM_AUDIT" onMatch="DENY" onMismatch="NEUTRAL"/>
</Filters>
</File>
<Console name="STDOUT">
<PatternLayout pattern="${pattern}"/>
<Filters>
<MarkerFilter marker="SQL_QUERY" onMatch="DENY" onMismatch="NEUTRAL"/>
<MarkerFilter marker="PUT_USER_MARKER" onMatch="DENY" onMismatch="NEUTRAL"/>
<MarkerFilter marker="GET_USER_MARKER" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="SQL_UPDATE_FULL" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="SQL_UPDATE" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="SQL_QUERY_LIST" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="SQL_DELETE" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="SQL_CREATE" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
</Filters>
</Console>
<AUDIT name="AUDIT">
<Filters>
<MarkerFilter marker="SYSTEM_AUDIT" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
</AUDIT>
</Appenders>
<Loggers>
<Root level="all">
<AppenderRef ref="AUDIT"/>
<AppenderRef ref="FILE"/>
<AppenderRef ref="STDOUT"/>
</Root>
</Loggers>
</Configuration>
Dans le paquet appender Je le appender coutume:
@Plugin(name = "AUDIT", category = "Core", elementType = "appender", printObject = true)
public class SystemAuditAppender extends AbstractAppender {
private final boolean includeStackTrace;
private final boolean includeExceptionCause;
private SystemAuditAppender(final String name,
final Layout<? extends Serializable> layout,
final Filter filter,
final boolean ignoreExceptions,
Boolean includeStackTrace,
Boolean includeExceptionCause) {
super(name, filter, layout, ignoreExceptions);
this.includeExceptionCause = includeExceptionCause;
this.includeStackTrace = includeStackTrace;
}
@Override
public void append(LogEvent event) {
System.err.println("IN APPENDER);
}
@PluginFactory
@SuppressWarnings("unused")
public static SystemAuditAppender createAppender(@PluginElement("Filter") Filter filter,
@PluginElement("Layout") Layout<? extends Serializable> layout,
@PluginElement(value = "AdditionalFields") final KeyValuePair[] additionalFields,
@PluginAttribute(value = "name") String name,
@PluginAttribute(value = "ignoreExceptions", defaultBoolean = true) Boolean ignoreExceptions,
@PluginAttribute(value = "includeStackTrace", defaultBoolean = true) Boolean includeStackTrace,
@PluginAttribute(value = "includeExceptionCause") Boolean includeExceptionCause) {
return new SystemAuditAppender(name, layout, filter, ignoreExceptions,
includeStackTrace, includeExceptionCause);
}
}
Si je déploie à wildfliy 10
je reçois messages d'erreur:
Traitement des erreurs l'élément de vérification ([appenders: null]): CLASS_NOT_FOUND erreur Impossible de localiser appender "vérification" de configuration de l'enregistreur "root"
Et il a dit: A pris 0,003248 secondes pour charger 0 plug-ins de paquet hu. pannonris.if3.web.util.appender
Donc, je ne vois pas le @plugin
lorsque le if3web-ear.ear
va se déployer. Qu'est-ce qui peut être un problème? Qu'est-ce que je dois faire pour travailler? Merci pour les aides!
Combien de modules web avez-vous? Où se trouve le "SystemAuditAppender" dans votre déploiement? Dans le module Web ou ailleurs dans le fichier EAR? –
J'ai ear-ejb et war et dans le module web où est l'appender, et j'ai juste un module web (war) – kodaek98
Est-ce que votre module EJB utilise aussi log4j2? Où dans le déploiement avez-vous placé les bocaux log4j2? –