Configuring log files in Application.cfc

Am removing this from the “Unsolicited log file rotation” thread as it’s not really on-topic there.

Back to this.

I had a look, but there’s no code that actually validates the passed-in struct and says “nah look you need these keys/values” as one might expect. Lucee just dives in and starts using it, and because I’m having to guess at what it wants (and get it wrong, obvs), all I’m getting is a NPE when I come to use writeLog next. NB: not from when Application.cfc processes, which is when I’d expect this stuff to be checked (and accordingly fail if it’s invalid), but when the code comes to use stuff that has previously been “configured”.

Am not sure this is a production-ready feature given these findings? At the very least, I cannot move forward with guessing how it works. Am out of guesses.


Adam

stack trace for the NPE plz, I’m following up with @micstriit about the details on this

I can also confirm. I played around with this yesterday and I thought the following would work:

    this.logs = {
       "application": {
           "appender":"resource",
           "appender-arguments":"path:{lucee-config}/logs/application.log",
           "layout":"classic",
           "level":"info",
           "name":"application"
       }
    }

but it gives me the following NPE:

lucee.runtime.exp.NativeException: java.lang.NullPointerException
  at lucee.commons.io.log.log4j2.Log4j2Engine.layoutClassDefintion(Log4j2Engine.java:142)
  at lucee.runtime.listener.ApplicationContextSupport.initLog(ApplicationContextSupport.java:335)
  at lucee.runtime.listener.ModernApplicationContext.initLog(ModernApplicationContext.java:1757)
  at lucee.runtime.listener.ModernApplicationContext.getLog(ModernApplicationContext.java:1731)
  at lucee.runtime.PageContextImpl.getLog(PageContextImpl.java:3754)
  at lucee.runtime.tag.Log.doStartTag(Log.java:217)
  at index_cfm$cf$c.call(/index.cfm:2)
  at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1043)
  at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:935)
  at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:219)
  at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:44)
  at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2475)
  at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2465)
  at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2436)
  at lucee.runtime.engine.Request.exe(Request.java:45)
  at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1198)
  at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1144)
  at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:97)
  at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:51)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:590)
  ...

(trimmed as the rest is just servlet and undertow output)

I also checked CFConfig style settings (I mean, why not?)

   this.logs = {
        "application":{
            "appender":"console",
            "appenderArguments":{
                "streamtype":"error"
            },
            "layout":"classic",
            "level":"error"
        }
    }

And got a similar NPE:

lucee.runtime.exp.NativeException: java.lang.NullPointerException
  at lucee.commons.io.log.log4j2.Log4j2Engine.layoutClassDefintion(Log4j2Engine.java:142)
  at lucee.runtime.listener.ApplicationContextSupport.initLog(ApplicationContextSupport.java:335)
  at lucee.runtime.listener.ModernApplicationContext.initLog(ModernApplicationContext.java:1757)
  at lucee.runtime.listener.ModernApplicationContext.getLog(ModernApplicationContext.java:1731)
  at lucee.runtime.PageContextImpl.getLog(PageContextImpl.java:3754)
  at lucee.runtime.tag.Log.doStartTag(Log.java:217)
  at index_cfm$cf$c.call(/index.cfm:2)
  at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1043)
  at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:935)
  at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:219)
  at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:44)
  at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2475)
  at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2465)
  at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2436)
  at lucee.runtime.engine.Request.exe(Request.java:45)
  at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1198)
  at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1144)
  at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:97)
  at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:51)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:590)
  at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
  at org.cfmlprojects.regexpathinfofilter.RegexPathInfoFilter.doFilter(RegexPathInfoFilter.java:47)
  at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  at java.base/java.lang.reflect.Method.invoke(Unknown Source)

(again, trimmed as you dont need undertow and fusion reactor stack trace, but I can provide)

I can see the sourecode defines the logs as:

And a log being defined as
import lucee.commons.io.log.Log;

But looking in Lucee/core/src/main/java/lucee/commons/io/log at 20660279ea7385c12cab4bef9742a8dab482c183 · lucee/Lucee · GitHub
Doesnt show a Log.java file as I would expect. Which I think means it’s in the loader (?)

Aha, which can be found here:

But that seems to be the acton to Log, rather than a log definition.

1 Like

Yup that’s what I got. No matter what I tried.

I also tried:

this.logs["application"] = "/Users/markdrew/Code/Personal/app_demo/application.log";

Which gave no error but did naathing! NAAATHING!

tracking in these tickets

LDEV-4153 NPE lucee.commons.io.log.log4j2.Log4j2Engine.layoutClassDefintion

LDEV-4152 add application.cfc code sample to log details page

2 Likes

Thanks to @markdrew & @Zackster for digging into this.