[ColdBox 4.0.0] LogBox Error "Variable THISAPPENDER is undefined"

It seems that my LogBox is not working correctly anymore. I am not sure what has happened. I am getting the following error in my CF application log when I try to add an entry:

LOGMESSAGE_8E7FE314E1985B14B58F040607D398AB: Variable THISAPPENDER is undefined.

My config in my ColdBox.cfc is:

logBox = {
appenders = {
coldboxTracer = {class=“coldbox.system.logging.appenders.ConsoleAppender”},
logFile = {class=“coldbox.system.logging.appenders.RollingFileAppender”,
properties = {fileMaxArchives=30, //Keep last 30 days
fileMaxSize=2000,
filename = “mylog”,
filePath=“logs”,
async=true}
}
},
// Root Logger
root = { levelmax=“INFO”, appenders="*" },
// Implicit Level Categories
info = [ “coldbox.system” ]
};

My logging is entry is like this: logbox.getRootLogger().info(“MY LOG ENTRY INFO”);

Any suggestions? Thanks

Looks like a var scoping issue:

thisAppender is not locally scoped like it should be. You probably have multiple requests creating a race condition.

I put in ticket:
https://ortussolutions.atlassian.net/browse/LOGBOX-17

In the mean time, you should be able to fix it by simple adding "var " in front of the thisAppnder declaration on the line of code I linked to.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

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

OK, I added the var scope and restarted my CF service. Error still occurs. The exception log points to: (C:\ColdFusion10\cfusion\wwwroot\coldbox\system\logging\Logger.cfc:340)

Thanks!

Might be related to Update Logger.cfc by sigmaprojects · Pull Request #211 · ColdBox/coldbox-platform · GitHub

Hmm, well technically I guess it could be related. Since no stack trace was provided, I guessed where the error was happening. Perhaps the var scoping issue I found was just a coincident. Chad, can you share a stack trace with us that shows where the error is actually happening?

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

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

The error does not occur onscreen but here is what the CF exception log has:

FYI… I just tried version coldbox-4.0.0-rc+00002-201410230827 and logging works fine. The version I am on where the error occurs is coldbox-4.0.0+00002-201501211101.

Thanks,
Chad

Ok, I see the issue. The problem is that the appender might exist in the root logger and not the local local. Therefore it does not exist locally.

Actually Don Q’s approach works but it is not ultimately kosher as it adds the missing appender when the appender belongs to the other logger category.

I think the best solution is to pass it into the threed to avoid the collision.

Luis Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com
P/F: 1-888-557-8057
Direct: (909) 248-3408

ColdBox Platform: http://www.coldbox.org

ContentBox Platform: http://www.gocontentbox.org
Linked In: http://www.linkedin.com/pub/3/731/483

Social: twitter.com/ortussolutions | twitter.com/coldbox | twitter.com/lmajano | twitter.com/gocontentbox

Remember Luis, as per the comment thread on the pull request that Don linked to, we can’t pass in the appender instance as an attribute to the thread or it will be duplicated by a deep copy (this is how cfthread works) It needs to be accessed from a shared scope.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

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

Well, the major parts have serializable=false, so it won’t do deep copies of everything. So in that part it is safe.

I will investigate another approach,

Luis Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com
P/F: 1-888-557-8057
Direct: (909) 248-3408

ColdBox Platform: http://www.coldbox.org

ContentBox Platform: http://www.gocontentbox.org
Linked In: http://www.linkedin.com/pub/3/731/483

Social: twitter.com/ortussolutions | twitter.com/coldbox | twitter.com/lmajano | twitter.com/gocontentbox

Can we look into the approach that was in that pull request? Somehow it didn’t get merged :slight_smile:

If this line is getting hit:

if( NOT hasAppenders() ){
target = getRootLogger();
}

then getAppender might just need to be modified to defer to its root logger.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

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