Excellent — thank you!

-- 
                                Jim Wise
                                jw...@draga.com





> On Dec 31, 2021, at 13:05, Juan Pablo Santos Rodríguez 
> <juanpablo.san...@gmail.com> wrote:
> 
> Hi Jürgen,
> 
> in order to ease file logging, last push adds an (unused) rolling file
> appender with some sensible defaults. This way, to enable file logging
> it'd only be needed to add the reference to the logger, f.ex.,
> something like:
> rootLogger.appenderRef.rolling.ref = RollingFile
> 
> in the jspwiki-custom.properties file. Also, every property from this
> new appender can be overwritten on the jspwiki-custom.properties file,
> as log4j is configured from the resulting properties parsed by
> JSPWiki. Hope that this makes the logging customization easier.
> 
> cheers and happy new year everyone!
> 
> On Sun, Dec 26, 2021 at 5:09 PM Jürgen Weber <juer...@jwi.de> wrote:
>> 
>> This config below in jspwiki-custom.properties works for me now, at
>> least it writes the log, will see in some days, if it indeed rolls.
>> Unfortunately log4j2 chose not to have a common prefix and thus a
>> namespace for their property names, so it is kind of messy.
>> 
>> # Give directory path where log files should get stored
>> property.basePath = /home/wiki/JSPWiki
>> 
>> # RollingFileAppender will print logs in file which can be rotated
>> based on time or size
>> appender.rolling.type = RollingFile
>> appender.rolling.name = fileLogger
>> appender.rolling.fileName= ${basePath}/jspwiki.log
>> appender.rolling.filePattern= ${basePath}/jspwiki_%d{yyyy-MM-dd}.log.gz
>> appender.rolling.layout.type = PatternLayout
>> appender.rolling.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} %level
>> [%t] [%c] [%M] [%l] - %msg%n
>> appender.rolling.policies.type = Policies
>> 
>> rootLogger.level = info
>> rootLogger.additivity = false
>> rootLogger.appenderRef.rolling.ref = fileLogger
>> 
>> Am Sa., 18. Dez. 2021 um 09:04 Uhr schrieb Juan Pablo Santos Rodríguez
>> <juanpablo.san...@gmail.com>:
>>> 
>>> Hi Jim,
>>> 
>>> for a quick check, I set up the log level to debug and saw the file with
>>> contents (I did the test with the cargo maven plugin, but that shouldn't
>>> matter).
>>> 
>>> Would you mind trying that? If you also have the log redirected to the
>>> stdout, do you see log there? Also, setting status=debug on the properties
>>> file, that should output all the loaded log4j2 configuration. What does it
>>> show?
>>> 
>>> Another difference between 2.10 and 2.11 is that the PropertyReader class
>>> was making a lot of info log statements that are now debug statements, but
>>> given some time, you'd definitely should see log messages on the file..
>>> 
>>> 
>>> Best regards,
>>> juan pablo
>>> 
>>> El sáb., 18 dic. 2021 0:45, Jim Wise <jw...@draga.com> escribió:
>>> 
>>>> Does this work for you?
>>>> 
>>>> I have this config (albeit with a different fileName), and while the files
>>>> are created, they do not receive any log messages.
>>>> --
>>>>                                Jim Wise
>>>>                                jw...@draga.com
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>>> On Dec 17, 2021, at 16:31, Juan Pablo Santos Rodríguez <
>>>> juanpablo.san...@gmail.com> wrote:
>>>>> 
>>>>> Hi Jürgen,
>>>>> 
>>>>> there's a commented section on the jspwiki.properties file setting up
>>>>> a rolling appender for the security log. The default configuration
>>>>> should be the same as before, translated from the equivalent log4j1
>>>>> configuration that was in place. With that example, the following
>>>>> works for me:
>>>>> 
>>>>> status = warn
>>>>> name = jspwiki-log4j2-configuration
>>>>> 
>>>>> apenders=console
>>>>> appender.console.type = Console
>>>>> appender.console.name = STDOUT
>>>>> appender.console.layout.type = PatternLayout
>>>>> appender.console.layout.pattern = %highlight{[%-5level]} %d{yyyy-MM-dd
>>>>> HH:mm:ss.SSS} [%t] %c{1.} - %msg%n %ex
>>>>> 
>>>>> appender.rolling.type = RollingFile
>>>>> appender.rolling.name = RollingFile
>>>>> appender.rolling.fileName = /tmp/jspwiki.log
>>>>> appender.rolling.filePattern = jspwiki.log.%d{dd-MMM}.log.gz
>>>>> appender.rolling.layout.type = PatternLayout
>>>>> appender.rolling.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %m%n
>>>>> appender.rolling.policies.type = Policies
>>>>> appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
>>>>> appender.rolling.policies.size.size=10MB
>>>>> appender.rolling.strategy.type = DefaultRolloverStrategy
>>>>> appender.rolling.strategy.max = 5
>>>>> 
>>>>> # Log to console, file
>>>>> loggers=jspwiki
>>>>> logger.jspwiki.name = org.apache.wiki
>>>>> logger.jspwiki.level = info
>>>>> logger.jspwiki.additivity = false
>>>>> logger.jspwiki.appenderRef.stdout.ref = STDOUT
>>>>> logger.jspwiki.appenderRef.rolling.ref = RollingFile
>>>>> 
>>>>> I agree that's somewhat verbose. Maybe another option could be use the
>>>>> 'jspwiki.use.external.logconfig=true' property and provide custom
>>>>> log4j2.[xml|properties|whatever expected by log4j] file? That's what's
>>>>> done f.ex. on the Docker image. What other default configuration would
>>>>> be more suitable? Perhaps providing some file appenders, but no using
>>>>> them by default? I don't have a strong opinion on that so, for the
>>>>> default log configuration with Log4J2 I went with the same as with
>>>>> Log4J.
>>>>> 
>>>>> Regarding the API change, it's not mandatory to do it in order to
>>>>> migrate to 2.11 (although I'd recommend it to do it as soon as
>>>>> possible, as the old methods should disappear on a-not-yet-defined
>>>>> moment in the future). The jspwiki-210-adapters artifact should
>>>>> reroute old methods to new ones. The jspwiki-210-test-adaptees tests
>>>>> that the former module behaves as expected so, if it doesn't, then
>>>>> that should be a bug :-/
>>>>> 
>>>>> The rationale of the change began on JSPWIKI-303 (to provide an API
>>>>> library); unfortunately this was easier said than done, as the
>>>>> signature of the methods included the WikiContext, which is tied to
>>>>> the WikiEngine, which in turn is tied to almost all JSPWiki code.
>>>>> Thus, all the interfaces extraction for the api module, and the
>>>>> changes on the WikiEngine et all between 2.10 and 2.11.
>>>>> 
>>>>> 
>>>>> HTH,
>>>>> juan pablo
>>>>> 
>>>>> On Fri, Dec 17, 2021 at 8:39 PM Jürgen Weber <juer...@jwi.de> wrote:
>>>>>> 
>>>>>> Finally found some time to update to 2.11.0.
>>>>>> Experience was mixed.
>>>>>> Had to port my plugins to the changed API (kind of frivolous to change
>>>>>> the API of a mature product, I dare to say, and break all existing
>>>>>> plugins), but this went rather smoothly.
>>>>>> But I didn't get the new logging to work. Do I really have to add some
>>>>>> 50 lines to my jspwiki-custom.properties to get a simple file logging?
>>>>>> Aren't there defaults?
>>>>>> Has anybody some simple lines to get a file log?
>>>>>> 
>>>>>> Thanks,
>>>>>> Juergen
>>>> 
>>>> 

Reply via email to