Hi
I’m fairly new to ColdBox, I’ve watched some of the videos and liked the look of CommandBox and LogBox so thought I’d give them a try.
I’ve installed CommandBox and done a “coldbox create app --installColdBoxBE”, I did the BE because I got an error otherwise.
The default app is there and seems to work fine.
When I try and put the line
log.info(‘hi’);
in the Main.cfc index method nothing happens, if I writeDump the log object I get a Component (coldbox.system.logging.Logger).
Should I be seeing something in the browser console?
Thanks
Hello, and welcome to ColdBox/LogBox!
Your LogBox installation is up and working, but the problem is you haven’t told it where you’d like it to log to yet! By default, LogBox is logging to a dummy appender until you tell it where to go instead. You can configure as many appenders for LogBox as you wish.
- database
- E-mail
- file
- console
- custom
To get up to speed, check out our PDF ref card here:
https://github.com/ColdBox/cbox-refcards/raw/master/LogBox/LogBox-Refcard.pdf
Adding in your LogBox configuration in ColdBox is easy. You can either add a “logbox” struct inside your /config/ColdBox.cfc file, or if you like to keep things organized, you can create a /config/LogBox.cfc dedicated to your LogBox config. Look in the PDF I linked to for exact syntax, but you can set up a log file with the following basic config:
logBox = {
appenders = {
logFile = {
class=“coldbox.system.logging.appenders.RollingFileAppender”,
properties = {
filename = “myLog”,
filePath=“logs”,
async=true
}
}
},
// Root Logger
root = { levelmax=“INFO”, appenders="*" },
};
Thanks!
~Brad
ColdBox Platform Evangelist
Ortus Solutions, Corp
E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com
Thanks Brad
In my ColdBox cfc I have
//LogBox DSL
logBox = {
// Define Appenders
appenders = {
coldboxTracer = { class=“coldbox.system.logging.appenders.ConsoleAppender” },
dbAppender = {
class=“coldbox.system.logging.appenders.DBAppender”,
properties = {
dsn = “myDB”, table=“api_logs”, autocreate=true, textDBType=“text”
}
}
},
// Root Logger
root = { levelmax=“INFO”, appenders="*" },
// Implicit Level Categories
OFF = [ “coldbox.system” ]
};
and in my Main.cfc index method I have
function index(event,rc,prc){
prc.welcomeMessage = “Welcome to ColdBox2!”;
coldboxTracer.info(‘main.cfc index method run to console’);
dblogger.info(‘main.cfc index method run’);
event.setView(“main/index”);
}
The DB appender works great and writes to the database, however the coldboxTracer also writes to the database when I expected it to write to the console, it has category “coldboxTracer” but appendername “DBAPPENDER”. What am I missing?
Thanks