[ColdBox 4.3.0] Logging to different files

34 views
Skip to first unread message

Pascal Peters

unread,
Sep 14, 2017, 9:39:55 AM9/14/17
to ColdBox Platform
Hi,

I want to log from different places in my application to different log files:
  • models.UserService to userLog
  • security module to securityLog
  • error handler to appLog
The logger is always injected using inject = "logbox:logger:{this}".
The issue I have is that all my messages are always logged in the 3 log files instead of 1 specific log file.
Can anybody tell me what I am missing?

This is my config LogBox.cfc

component{


 
// Configure LogBox
 
function configure(){
 
 
//LogBox DSL
 logBox
= {
     
// Define Appenders
     
appenders = {
 
            coldboxTracer = { class="coldbox.system.logging.appenders.ConsoleAppender" },
             coldboxLog = {
                class="coldbox.system.logging.appenders.FileAppender",
                properties
= {
                    filepath
= "/logs/",
                    filename
= "appLog"
                 }
             },
       userLog
= {
         
class="coldbox.system.logging.appenders.FileAppender",
         properties
= {
             filepath
= "/logs/",
             filename
= "userLog"
         
}
       
},
       securityLog
= {
         
class="coldbox.system.logging.appenders.FileAppender",
         properties
= {
             filepath
= "/logs/",
             filename
= "securityLog"
         
}
       
}
     
}
     
// Root Logger
     
,root = { levelMin='FATAL', levelMax='ERROR', appenders="coldboxTracer" }
     
// categories
     
,categories = {
          models
.UserService = { levelMin = "INFO", levelMax = "INFO", appenders = "userLog" },
          modules_app
.security = { levelMin = "INFO", levelMax = "INFO", appenders = "securityLog" },
          handlers
.error = { levelMin='FATAL', levelMax = "WARN", appenders = "coldboxLog" }
     
}
   
};
 
 
}


}


Thx
Pascal

br...@bradwood.com

unread,
Sep 14, 2017, 9:55:50 AM9/14/17
to col...@googlegroups.com
Can you show us an example log message from each category.  my guess is the logging categories are not what you expect, so they're hitting the root logger.

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: br...@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com 
 
 
--------- Original Message ---------

          models
.UserService={ levelMin ="INFO", levelMax ="INFO", appenders ="userLog"},

          modules_app
.security ={ levelMin ="INFO", levelMax ="INFO", appenders ="securityLog"},
          handlers
.error ={ levelMin='FATAL', levelMax ="WARN", appenders ="coldboxLog"}
     
}
   
};
 
 
}


}
 
 
Thx
Pascal

 

--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coldbox/4f5e0a99-9a60-4605-b43b-73afd2873855%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pascal Peters

unread,
Sep 14, 2017, 10:11:41 AM9/14/17
to ColdBox Platform
"Severity","Appender","Date","Time","Category","Message"
"ERROR","COLDBOXLOG","09/14/2017","16:04:31","handlers.Error","CFErrorType=expression  CFMessage=variable [GENERATEERROR] doesn't exist ..."
"INFO","COLDBOXLOG","09/14/2017","16:04:42","models.UserService","Update: User with id 10007 {""department_id"":""2"",""lastName"":""User"",""firstName"":""Test"",""user_id"":""10007"",""email"":""te...@stepstone.com""}"
"INFO","COLDBOXLOG","09/14/2017","16:04:48","modules_app.security.handlers.Login","Logging out user ad...@stepstone.com"


The "Appender" is different in each file (COLDBOXLOG, SECURITYLOG or USERLOG) but otherwise they are identical

Thx 

Op donderdag 14 september 2017 15:55:50 UTC+2 schreef Brad Wood:

br...@bradwood.com

unread,
Sep 14, 2017, 2:35:23 PM9/14/17
to col...@googlegroups.com
 
Hmm, that all looks in order to be honest.  At this point I'd try one of two things:
 
1) Simply your config by reducing to one appender and one category to test and see if it works then
2) Dig into the LogBox code with dump/aborts and start tracing the sucker through to see where it's going wrong.
 
Maybe start with the first and confirm that your loggers that you're using have the correct category that you expect.  log.getCategory()
--------- Original Message ---------

Pascal Peters

unread,
Sep 15, 2017, 8:03:18 AM9/15/17
to ColdBox Platform
Hi Brad,

Thanks for the input. I started debugging and found the issue. It is in the definition of the categories. I need to put quotes around category names if they contain dots. Otherwise it wil create nested keys that won't come up in the hierarchy lookup and I get the config from the root logger.

So the solution was

,categories = {
"models.UserService" = { levelMin = "INFO", levelMax = "INFO", appenders = "userLog" },
"modules_app.security" = { levelMin = "INFO", levelMax = "INFO", appenders = "securityLog" },
"handlers.error" = { levelMin='FATAL', levelMax = "WARN", appenders = "coldboxLog" }
}

Thx for your time
Pascal

Op donderdag 14 september 2017 20:35:23 UTC+2 schreef Brad Wood:

br...@bradwood.com

unread,
Sep 15, 2017, 10:57:22 AM9/15/17
to col...@googlegroups.com
Oh man, tricky tricky!  Good catch and I'm glad it's working for you now!

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: br...@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com 
 
 
--------- Original Message ---------
Subject: Re: Re: [coldbox:26565] [ColdBox 4.3.0] Logging to different files
From: "Pascal Peters" <pascal...@gmail.com>
Date: 9/15/17 7:03 am
To: "ColdBox Platform" <col...@googlegroups.com>

--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages