I would like to use JLog on different files in my component.

At the moment I'm adding this to my __contruct method:

JLog::addLogger( array( 'text_file' => 'com_bestia.log.php' ) );

But is it possible to add this only once to one file and use it on different other files?

1 Answer 1


I don't think what you're trying to do is possible cause the component won't know when to, and when not to log errors.

What you can do is, load the JLog class and tell your component to log all errors, like so

JLoader::register('JLog', JPATH_LIBRARIES . '/joomla/log/log.php');

        'text_file' => 'com_bestia.log.php'

Then, let's say (for example) you want to check if a file exists and want to log an error if it doesn't exist:

if (JFile::exists('path_to_file'))
    // import the file
    JLog::add('File does not exist', JLog::WARNING, 'com_bestia');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.