Re: Log4j2 Appender attributes with strict xml config
It didn't go to my spam folder. I just haven't had the time to really think about it and respond. Ralph On Oct 22, 2013, at 1:11 AM, alexander.rat...@materna.de wrote: Hi, just checking if my previous mail went to spamfolder or something because I got no feedback yet. Best Regards, Alex -Ursprüngliche Nachricht- Von: Rathai, Alexander Gesendet: Donnerstag, 17. Oktober 2013 18:16 An: log4j-user@logging.apache.org Betreff: AW: Log4j2 Appender attributes with strict xml config *snip* - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Log4j2 Appender attributes with strict xml config
Perfection may be hard to achieve, but if Alexander's suggestions are an improvement over the current schema, should we add them to the current code base? Remko On Tuesday, October 15, 2013, Gary Gregory wrote: On Mon, Oct 14, 2013 at 11:10 AM, Ralph Goers ralph.go...@dslextreme.com javascript:; wrote: On Oct 14, 2013, at 7:31 AM, Gary Gregory garydgreg...@gmail.comjavascript:; wrote: The current idea I have is that the XML Schema would reflect exactly the code that is running. We should start with that. AFAIK, the current code we have does not allow open-ended XML fragments, but I could be wrong... Gary Of course it allows open-ended XML fragments. If the user provides their own Appender as a plugin they are free to create other plugins that the Appender can then reference. The same is true for Filters, Lookups, etc. XMLConfiguration and JSONConfiguration don't care about specific element names - only that they map to a defined plugin. So any scheme you come up with to generate a fully strict schema would have to be able to account for user defined plugins. I should have been more specific, or there is another piece I do not understand. If I or Alexander provide our own Appender, they will be annotated with Log4j2 annotations. Today, yes, the XML is open-ended, but not per XML Schema. In my imaginary yet-to-be-implemented system, you would tell Log4j, at developement or build time of your app, to rebuild the metadata such that: (1) the normal config knows about my custom appender, and (2) I can generate a new XML Schema. Gary Ralph - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.orgjavascript:; For additional commands, e-mail: log4j-user-h...@logging.apache.orgjavascript:; -- E-Mail: garydgreg...@gmail.com javascript:; | ggreg...@apache.orgjavascript:; Java Persistence with Hibernate, Second Edition JUnit in Action, Second Edition Spring Batch in Action Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.orgjavascript:; For additional commands, e-mail: log4j-user-h...@logging.apache.orgjavascript:;
Re: Log4j2 Appender attributes with strict xml config
On Wednesday, October 16, 2013, Gary Gregory wrote: On Wed, Oct 16, 2013 at 8:48 AM, Remko Popma remko.po...@gmail.comjavascript:; wrote: Perfection may be hard to achieve, but if Alexander's suggestions are an improvement over the current schema, should we add them to the current code base? Probably but where are they? It looks like some text was lost in a reply to this thread. Gary Hm, it's a bit hard to do this via mail (but perhaps that's just me...) Alexander, would you mind raising a JIRA ticket and appending your modifications to it? A diff patch file would be ideal. Best regards, Remko Remko On Tuesday, October 15, 2013, Gary Gregory wrote: On Mon, Oct 14, 2013 at 11:10 AM, Ralph Goers ralph.go...@dslextreme.com javascript:; javascript:; wrote: On Oct 14, 2013, at 7:31 AM, Gary Gregory garydgreg...@gmail.comjavascript:; javascript:; wrote: The current idea I have is that the XML Schema would reflect exactly the code that is running. We should start with that. AFAIK, the current code we have does not allow open-ended XML fragments, but I could be wrong... Gary Of course it allows open-ended XML fragments. If the user provides their own Appender as a plugin they are free to create other plugins that the Appender can then reference. The same is true for Filters, Lookups, etc. XMLConfiguration and JSONConfiguration don't care about specific element names - only that they map to a defined plugin. So any scheme you come up with to generate a fully strict schema would have to be able to account for user defined plugins. I should have been more specific, or there is another piece I do not understand. If I or Alexander provide our own Appender, they will be annotated with Log4j2 annotations. Today, yes, the XML is open-ended, but not per XML Schema. In my imaginary yet-to-be-implemented system, you would tell Log4j, at developement or build time of your app, to rebuild the metadata such that: (1) the normal config knows about my custom appender, and (2) I can generate a new XML Schema. Gary Ralph - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.orgjavascript:; javascript:; For additional commands, e-mail: log4j-user-h...@logging.apache.orgjavascript:; javascript:; -- E-Mail: garydgreg...@gmail.com javascript:; javascript:; | ggreg...@apache.org javascript:; javascript:; Java Persistence with Hibernate, Second Edition JUnit in Action, Second Edition Spring Batch in Action Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.orgjavascript:; javascript:; For additional commands, e-mail: log4j-user-h...@logging.apache.orgjavascript:; javascript:; -- E-Mail: garydgreg...@gmail.com javascript:; | ggreg...@apache.orgjavascript:; Java Persistence with Hibernate, Second Edition http://www.manning.com/bauer3/ JUnit in Action, Second Edition http://www.manning.com/tahchiev/ Spring Batch in Action http://www.manning.com/templier/ Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory
Re: Log4j2 Appender attributes with strict xml config
Alexander , XML validation against the XML Schema is not fully baked because the Log4j 2 XML Schema is incomplete. Due to the current dynamic nature of the configuration file (it's schema is tied to the Java code and the annotations used), we need to generate the XML Schema based on these annotations in the same way that the annotations are currently processed to create the metadata configuration. Simone had proposed a different to do configuration, but that has not gone anywhere yet, and I am not sure it dealt with XML validation. Gary On Mon, Oct 14, 2013 at 10:09 AM, alexander.rat...@materna.de wrote: Hi, I'm using log4j2-beta9 and want to configure it using a log4j2.xml in strict mode. My issue is: how do I specify attributes that are not in the shipped schema file? An Example: ?xml version=1.0 encoding=UTF-8 ? Configuration status=DEBUG strict=true monitorInterval=5 name=TestingAttributes verbose=true xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:noNamespaceSchemaLocation=Log4j-config.xsd Properties /Properties Appenders Appender type=Console name=SYSERR target=SYSTEM_ERR !-- cvc-complex-type.3.2.2: Attribute 'target' is not allowed to appear in element 'Appender'. -- Layout Type=PatternLayout Pattern%date{dd.MM. HH:mm:ss,SSS} %5p %logger %m%n/Pattern /Layout Filters Filter type=MarkerFilter marker=FLOW onMatch=DENY onMismatch=NEUTRAL / Filter type=MarkerFilter marker=EXCEPTION onMatch=DENY onMismatch=NEUTRAL / /Filters /Appender /Appenders Loggers Root level=debug AppenderRef ref=SYSERR / /Root /Loggers /Configuration Notice that I want to set the appender to have the target SYSTEM_ERR but the attribute is not allowed in strict mode. target=SYSTEM_ERR !-- cvc-complex-type.3.2.2: Attribute 'target' is not allowed to appear in element 'Appender'. -- I could always edit the Log4j-config.xsd and allow that attribute there but that would be kind of wrong also because not all appenders have a target attribute. As searching the web didn't help me so far, I'm asking you: Is there anything I'm missing in configuring Log4j2 in strict XML mode? I am for now using the following classes as a workaround: import org.apache.logging.log4j.core.config.*; import org.apache.logging.log4j.core.config.plugins.*; /** * Simple ConfigurationFactory that returns a {@link StrictXMLConfigurationFactory} * * @author a href=mailto:alexander.rat...@materna.de;Alexander Rathai/a */ @Plugin(name = StrictXMLConfigurationFactory, category = ConfigurationFactory) @Order(4) public class StrictXMLConfigurationFactory extends ConfigurationFactory { /** * Valid file extensions for XML files. */ public static final String[] SUFFIXES = new String[]{.xml}; /** * @see org.apache.logging.log4j.core.config.ConfigurationFactory#getConfiguration(org.apache.logging.log4j.core.config.ConfigurationFactory.ConfigurationSource) */ @Override public Configuration getConfiguration(ConfigurationSource source) { return new StrictXMLConfiguration(source); } /** * @see org.apache.logging.log4j.core.config.ConfigurationFactory#getSupportedTypes() */ @Override public String[] getSupportedTypes() { return XMLConfigurationFactory.SUFFIXES; } } And import java.util.*; import org.apache.logging.log4j.core.config.*; import org.apache.logging.log4j.core.config.ConfigurationFactory.ConfigurationSource; /** * Lets the base class {@link XMLConfiguration} do all the hard work and patch the object tree before it is being used by {@link BaseConfiguration} * * @author a href=mailto:alexander.rat...@materna.de;Alexander Rathai/a */ public class StrictXMLConfiguration extends XMLConfiguration { /** * @param configSource */ public StrictXMLConfiguration(ConfigurationSource configSource) { super(configSource); } /** * @see org.apache.logging.log4j.core.config.XMLConfiguration#setup() */ @Override public void setup() { super.setup();
Re: Log4j2 Appender attributes with strict xml config
The current idea I have is that the XML Schema would reflect exactly the code that is running. We should start with that. AFAIK, the current code we have does not allow open-ended XML fragments, but I could be wrong... Gary On Mon, Oct 14, 2013 at 10:25 AM, alexander.rat...@materna.de wrote: So basically when you want strict validation you want it really strict, i.e. not only for the base types like appenders, filters but also their attributes? As far as I understand that would result in a bigger schema where each type is defined in the schema and the config looks more like the non-strict version. User supplied types would be impossible then, unless they are defined as a generic type in the schema which allows for KeyValuePairs or such (like I did in the edited schema below). Best Regards, Alex -Ursprüngliche Nachricht- Von: Gary Gregory [mailto:garydgreg...@gmail.com] Gesendet: Montag, 14. Oktober 2013 16:18 An: Log4J Users List Betreff: Re: Log4j2 Appender attributes with strict xml config Alexander , XML validation against the XML Schema is not fully baked because the Log4j 2 XML Schema is incomplete. Due to the current dynamic nature of the configuration file (it's schema is tied to the Java code and the annotations used), we need to generate the XML Schema based on these annotations in the same way that the annotations are currently processed to create the metadata configuration. Simone had proposed a different to do configuration, but that has not gone anywhere yet, and I am not sure it dealt with XML validation. Gary On Mon, Oct 14, 2013 at 10:09 AM, alexander.rat...@materna.de wrote: Hi, I'm using log4j2-beta9 and want to configure it using a log4j2.xml in strict mode. My issue is: how do I specify attributes that are not in the shipped schema file? An Example: ?xml version=1.0 encoding=UTF-8 ? Configuration status=DEBUG strict=true monitorInterval=5 name=TestingAttributes verbose=true xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:noNamespaceSchemaLocation=Log4j-config.xsd Properties /Properties Appenders Appender type=Console name=SYSERR target=SYSTEM_ERR !-- cvc-complex-type.3.2.2: Attribute 'target' is not allowed to appear in element 'Appender'. -- Layout Type=PatternLayout Pattern%date{dd.MM. HH:mm:ss,SSS} %5p %logger %m%n/Pattern /Layout Filters Filter type=MarkerFilter marker=FLOW onMatch=DENY onMismatch=NEUTRAL / Filter type=MarkerFilter marker=EXCEPTION onMatch=DENY onMismatch=NEUTRAL / /Filters /Appender /Appenders Loggers Root level=debug AppenderRef ref=SYSERR / /Root /Loggers /Configuration Notice that I want to set the appender to have the target SYSTEM_ERR but the attribute is not allowed in strict mode. target=SYSTEM_ERR !-- cvc-complex-type.3.2.2: Attribute 'target' is not allowed to appear in element 'Appender'. -- I could always edit the Log4j-config.xsd and allow that attribute there but that would be kind of wrong also because not all appenders have a target attribute. As searching the web didn't help me so far, I'm asking you: Is there anything I'm missing in configuring Log4j2 in strict XML mode? I am for now using the following classes as a workaround: import org.apache.logging.log4j.core.config.*; import org.apache.logging.log4j.core.config.plugins.*; /** * Simple ConfigurationFactory that returns a {@link StrictXMLConfigurationFactory} * * @author a href=mailto:alexander.rat...@materna.de;Alexander Rathai/a */ @Plugin(name = StrictXMLConfigurationFactory, category = ConfigurationFactory) @Order(4) public class StrictXMLConfigurationFactory extends ConfigurationFactory { /** * Valid file extensions for XML files. */ public static final String[] SUFFIXES = new String[]{.xml}; /** * @see org.apache.logging.log4j.core.config.ConfigurationFactory#getConfigura tion(org.apache.logging.log4j.core.config.ConfigurationFactory.Configu rationSource) */ @Override public Configuration getConfiguration(ConfigurationSource source) { return new StrictXMLConfiguration(source); } /** * @see org.apache.logging.log4j.core.config.ConfigurationFactory#getSupported Types() */ @Override public String[] getSupportedTypes() { return
Re: Log4j2 Appender attributes with strict xml config
On Oct 14, 2013, at 7:31 AM, Gary Gregory garydgreg...@gmail.com wrote: The current idea I have is that the XML Schema would reflect exactly the code that is running. We should start with that. AFAIK, the current code we have does not allow open-ended XML fragments, but I could be wrong... Gary Of course it allows open-ended XML fragments. If the user provides their own Appender as a plugin they are free to create other plugins that the Appender can then reference. The same is true for Filters, Lookups, etc. XMLConfiguration and JSONConfiguration don't care about specific element names - only that they map to a defined plugin. So any scheme you come up with to generate a fully strict schema would have to be able to account for user defined plugins. Ralph - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Log4j2 Appender attributes with strict xml config
On Mon, Oct 14, 2013 at 11:10 AM, Ralph Goers ralph.go...@dslextreme.com wrote: On Oct 14, 2013, at 7:31 AM, Gary Gregory garydgreg...@gmail.com wrote: The current idea I have is that the XML Schema would reflect exactly the code that is running. We should start with that. AFAIK, the current code we have does not allow open-ended XML fragments, but I could be wrong... Gary Of course it allows open-ended XML fragments. If the user provides their own Appender as a plugin they are free to create other plugins that the Appender can then reference. The same is true for Filters, Lookups, etc. XMLConfiguration and JSONConfiguration don't care about specific element names - only that they map to a defined plugin. So any scheme you come up with to generate a fully strict schema would have to be able to account for user defined plugins. I should have been more specific, or there is another piece I do not understand. If I or Alexander provide our own Appender, they will be annotated with Log4j2 annotations. Today, yes, the XML is open-ended, but not per XML Schema. In my imaginary yet-to-be-implemented system, you would tell Log4j, at developement or build time of your app, to rebuild the metadata such that: (1) the normal config knows about my custom appender, and (2) I can generate a new XML Schema. Gary Ralph - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org -- E-Mail: garydgreg...@gmail.com | ggreg...@apache.org Java Persistence with Hibernate, Second Edition JUnit in Action, Second Edition Spring Batch in Action Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org