Seperate log files using LogBox

101 views
Skip to first unread message

Daniel Mejia

unread,
Feb 8, 2012, 9:32:22 PM2/8/12
to ColdBox Platform
Can I get some help setting up seperate log files. In my config I
have:

//LogBox DSL
logBox = {
// Define Appenders
appenders = {
coldboxTracer =
{ class="coldbox.system.logging.appenders.ColdboxTracerAppender" },
coldboxFile = {

class="coldbox.system.logging.appenders.AsyncRollingFileAppender",
properties={filePath="logs",
fileName="orders",
autoExpand=true,
fileMaxSize=2000,
fileMaxArchives=2}
}
},
// Root Logger
root = { levelmax="INFO", appenders="*" },
// Implicit Level Categories
info = [ "coldbox.system" ]
};
and when I use the following this inserts the log into /logs/
orders.log

getPlugin("Logger").logEntry("information","Successful -
#OrderStruct.details#","");

I added
coldboxFile2 = {

class="coldbox.system.logging.appenders.AsyncRollingFileAppender",
properties={filePath="logs",
fileName="login",
autoExpand=true,
fileMaxSize=2000,
fileMaxArchives=2}
}
but how do I call the plugin logger so that it inserts the log into /
logs/login.log?

Leonty Belskiy

unread,
Feb 9, 2012, 4:33:12 PM2/9/12
to col...@googlegroups.com
You need to define new logger - right now you have root logger:

root = { levelmax="INFO", appenders="*" }

add new one:

myLog = { levelmax="INFO", appenders="coldboxFile2" }

So this new logger with use only new appender.
You can call it in multiple ways:

With wirebox:
logbox:myLog

Or from controller:
getController().getLogBox().getLogger("myLog")

http://wiki.coldbox.org/wiki/LogBox.cfm

Good luck,
Leonty

On Thu, Feb 9, 2012 at 3:32 AM, Daniel Mejia <webma...@gmail.com> wrote:
> coldboxFile

Daniel Mejia

unread,
Feb 10, 2012, 2:45:30 PM2/10/12
to ColdBox Platform
Thanks. I can now get specific log files.

In config I have two difined loggers:

root = { levelmax="INFO", appenders="*" },
mylog = { levelmax="INFO", appenders="coldboxFile2" }

root logger logs everything, so I thought could do this so that only
mylog logs what I trigger:
root = { levelmax="INFO", appenders="coldboxTracer,coldboxFile" },
mylog = { levelmax="INFO", appenders="coldboxFile2" }

but now mylog doesn't log anything and root still logs everything.

Daniel Mejia

unread,
Feb 11, 2012, 3:09:01 AM2/11/12
to ColdBox Platform
Is root logger suppose to log everything even if you use different
appenders for specific logging?

Brad Wood

unread,
Feb 11, 2012, 5:50:44 AM2/11/12
to col...@googlegroups.com
No, it's there as the default logger that every other logger inherits from it. You can set it up with whatever appenders you want, and at run time the log levels of the logger and appenders in combination (most restrictive) will decide what actualy gets logged.

Feel free to create as many named loggers as you want to meet your logging needs. Logger names (or categories) can be named anything you want, but they are intended to be dot-delimited paths like your CFC packages.

In your config, if you name your logger categories things like:

"coldbox.system"
"com.mysite.prducts"
"com.mysite.security"
"com.mysite.security.permssionBean"

Then you can inject "logbox:logger:{this}" into your CFCs which automatically names the logger after the full component path and inherits its settings from the closest named logging category. That way you an control logging settings in an entire package (ex. "com.mysite.security") by changing the settings for that logging category in your config.

http://wiki.coldbox.org/wiki/logbox.cfm

Thanks!

~Brad

Sent from my ASUS Eee Pad

Daniel Mejia <webma...@gmail.com> wrote:

>Is root logger suppose to log everything even if you use different
>appenders for specific logging?
>

>--
>You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
>To post to this group, send email to col...@googlegroups.com
>To unsubscribe from this group, send email to coldbox-u...@googlegroups.com
>For more options, visit this group at http://groups-beta.google.com/group/coldbox
>For News, visit http://blog.coldbox.org
>For Documentation, visit http://wiki.coldbox.org
>

Reply all
Reply to author
Forward
0 new messages