question

is there a way to have DatabaseAppenders use the datasource structure within the Coldbox.cfc to get the location/info of the specified database?

//Datasources
datasources = {
main_dsn = {name=“main-test”, dbType=“mysql”, username="…", password="…"},
log_dsn = {name=“logs-test”, dbType=“mysql”, username="…", password="…"}
};

//LogBox DSL
logBox = {
// Define Appenders
appenders = {
dbAppender = { class=“coldbox.system.logging.appenders.DBAppender”,
properties={
dsn=‘log_dsn’,table=‘logs’,autocreate=true,textDBType=‘longtext’
}
}
},
// Root Logger
root = {levelMin=“FATAL”, levelMax=“ERROR”, appenders="*"}
};


Jeremy R. DeYoung
Phone:615.261.8201

RantsFromAMadMan.com

You won’t be able to access your configuration inside of the coldbox.cfc due to the chicken and egg problem. What you can do though, is load up your data sources in the config, and then implement an interceptor that listens for afterConfigurationLoad and sets up LogBox using the datasource settings via the programmatic config.

Thanks!

~Brad

Actually you can it is just a variable. Use datasources

True that. Just make sure your datasources struct is defined before your logbox struct.

If you have any environment overrides though that change the datasources, that won’t work unless you also re-set the logBox datasources in the environment functions.

Thanks!

~Brad

so awesome. you rock guys!


Jeremy R. DeYoung
Phone:615.261.8201

RantsFromAMadMan.com