Cfconfig logger

Hi There,

Is there a way that I can update all loggers at once?
I want to set all loggers to a log level (of debug or trace) for some temporary debugging - then revert them all back to error - afterwards.

I can’t see a way to do that in the docs or the command-line help.
So just thought I would check.

Thanks!

CFConfig will modify the config XML files that Lucee reads when it starts (or restarts). It can’t modify the running values in memory. I’m not actually sure if Lucee allows this, but if it did, it would be in the admin API.

Hi @bdw429s ,

I am happy for it to be after a restart.
It is for dev/test/staging machines.

I am just checking if it is possible - or if I need to do them singularly?

Thanks.

Got it. You can enable the config file watcher like so:

cfconfig set watchConfigFilesForChangesEnabled=true

and it should pick them up within a minute or so.

Hi Brad,

Sorry - but I don’t think we’re understanding each other.
At the moment I have XX log files defined.

Can I update all XX in the one operation to TRACE,
Then in another single operation back to INFO.

Or do I need a single CFCONFIG command per log I want to change?

Thanks.

If you are happy manually restarting Lucee to pick up the changes, or configuring it to watch for config file changes, then adjusting the log level of a single logger is easy.

cfconfig set loggers.thread.level=INFO
cfconfig set loggers.orm.level=TRACE

HI @bdw429s,

I think from your responses - the answer is “no”. “You cannot” set the level attribute for ALL logs in one command.
Which is fine.
I can create a script to do it.

Have an awesome week!

Sorry, I never actually directly answered that question. Technically you could create a JSON file like so:

{
  "loggers" : {
    "thread"" : {
      "level" : "INFO"
    },
    "orm"" : {
      "level" : "INFO"
    },
    "application"" : {
      "level" : "INFO"
    },
    ...
  }
}

And then import it with the --append flag so it’s not a full overwrite

cfconfig import loggerOverrides.json --append

You could even put a ${level} place holder in the JSON

{
  "loggers" : {
    "thread"" : {
      "level" : "${level}"
    },
    "orm"" : {
      "level" : "${level}"
    },
    "application"" : {
      "level" : "${level}"
    },
    ...
  }
}

and do this

set level=TRACE
cfconfig import loggerOverrides.json --append

# later...
set level=INFO
cfconfig import loggerOverrides.json --append

It’s not currently possible to do anything like this however

cfconfig set loggers.*.level=TRACE

though that’s a very interesting use case that would probably be possible to support if we wanted to. I’ve honestly never thought about it before, but it could have some utility to update all datasources, loggers, scheduled tasks, etc, etc.