<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ollehar</id>
	<title>Joomla! Documentation - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ollehar"/>
	<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/Special:Contributions/Ollehar"/>
	<updated>2026-06-29T21:28:17Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Using_JLog&amp;diff=453333</id>
		<title>Using JLog</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Using_JLog&amp;diff=453333"/>
		<updated>2017-10-20T14:42:26Z</updated>

		<summary type="html">&lt;p&gt;Ollehar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
Using &#039;&#039;&#039;JLog&#039;&#039;&#039; can be very useful in components when analysing the performance of custom extensions - or analysing where extensions are giving issues. Note this should be used in tandem with php exceptions - not as a replacement. See [[S:MyLanguage/Exceptions and Logging in Joomla 1.7 and Joomla Platform 11.1|Exceptions and Logging in Joomla 1.7 and Joomla Platform 11.1]] for more information on this.&amp;lt;/translate&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Calling the class == &amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
To use JLog you need to call the JLog class. Done through the following code:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    jimport(&#039;joomla.log.log&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Basic File Logging == &amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
Often you may wish to display an error log message and log to an error file. Joomla allows this natively through the &amp;lt;tt&amp;gt;JLog::add&amp;lt;/tt&amp;gt; function. For example:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::add(JText::_(&#039;JTEXT_ERROR_MESSAGE&#039;), JLog::WARNING, &#039;jerror&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
Adding the category of jerror means that this message will also be displayed to users. To only write to file you can easily drop that parameter and simply use:&amp;lt;/translate&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    JLog::add(JText::_(&#039;JTEXT_ERROR_MESSAGE&#039;), JLog::WARNING);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Logging a specific extension == &amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
Sometimes it may be useful to log the errors to a specific file. In this case you can.&amp;lt;/translate&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.errors.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets messages of all log levels to be sent to the file&lt;br /&gt;
        JLog::ALL,&lt;br /&gt;
        // The log category/categories which should be recorded in this file&lt;br /&gt;
        // In this case, it&#039;s just the one category from our extension, still&lt;br /&gt;
        // we need to put it inside an array&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
Now remember to change the category when you add a log message. Such as in the example below.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::add(JText::_(&#039;JTEXT_ERROR_MESSAGE&#039;), JLog::WARNING, &#039;com_helloworld&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; You may wish to combine this with the [[S:MyLanguage/Display error messages and notices|Display error messages and notices]] section to display visable error notifications to users.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Logging specific priorities == &amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
You can also add an additional logger to capture only critical and emergency log notifications:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.critical_emergency.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets critical and emergency log level messages to be sent to the file&lt;br /&gt;
        JLog::CRITICAL + JLog::EMERGENCY,&lt;br /&gt;
        // The log category which should be recorded in this file&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
You can also exclude a specific category from being included. For example, to log all but DEBUG messages:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.all_but_debug.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets all but DEBUG log level messages to be sent to the file&lt;br /&gt;
        JLog::ALL &amp;amp; ~JLog::DEBUG,&lt;br /&gt;
        // The log category which should be recorded in this file&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
Notice how &#039;&#039;&#039;bitwise&#039;&#039;&#039; operations (bitwise AND, &amp;amp;; and bitwise NOT, ~) are used to calculate the accepted log levels.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Formatting the logfile == &amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
The first parameter to addLogger can have a few optional additional settings in addition to the &amp;lt;tt&amp;gt;text_file&amp;lt;/tt&amp;gt; entry.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
There is for example the entry &amp;lt;tt&amp;gt;text_entry_format&amp;lt;/tt&amp;gt;, specifying the format of each line in your logfile.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
The default format is:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &#039;{DATETIME} {PRIORITY}      {CATEGORY}      {MESSAGE}&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
Here is an example of a different format which shows how to omit the category:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.critical_emergency.php&#039;,&lt;br /&gt;
             // Sets the format of each line&lt;br /&gt;
             &#039;text_entry_format&#039; =&amp;gt; &#039;{DATETIME} {PRIORITY} {MESSAGE}&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets all but DEBUG log level messages to be sent to the file&lt;br /&gt;
        JLog::ALL &amp;amp; ~JLog::DEBUG,&lt;br /&gt;
        // The log category which should be recorded in this file&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
In addition to the placeholders shown above in the default string, the following values are available:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    {CLIENTIP}&lt;br /&gt;
    {TIME}&lt;br /&gt;
    {DATE}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
There is an additional optional boolean parameter &amp;lt;tt&amp;gt;text_file_no_php&amp;lt;/tt&amp;gt;, which specifies whether the log file is prepended with the usual prefix of:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    #&lt;br /&gt;
    #&amp;lt;?php die(&#039;Forbidden.&#039;);?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Usually you should not set this setting to false. Log files should not be readable from the outside, since they can provide valuable information about your system for attackers.&lt;br /&gt;
Only dabble with this if you know what you&#039;re doing!&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
Furthermore, if you want to store the log file somewhere else than the logging path configured in the Joomla! settings, you can there is the &amp;lt;tt&amp;gt;text_file_path&amp;lt;/tt&amp;gt; setting.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Exceptions == &amp;lt;!--T:25--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:26--&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;JLog::add()&amp;lt;/code&amp;gt; will throw an exception if it can&#039;t write to the log file. To avoid this, you&#039;d have to either wrap the call in another function, or implement your own logger class and then include it with:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Use mycustomlogger&lt;br /&gt;
             &#039;logger&#039; =&amp;gt; &#039;mycustomlogger&#039;,&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.errors.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        JLog::ALL,&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:24--&amp;gt;&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[category:Joomla! 1.7]]&lt;br /&gt;
[[category:Joomla! 2.5]]&lt;br /&gt;
[[category:Joomla! 3.0]]&lt;br /&gt;
[[category:Joomla! 3.x]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ollehar</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Using_JLog&amp;diff=453297</id>
		<title>Using JLog</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Using_JLog&amp;diff=453297"/>
		<updated>2017-10-20T12:08:35Z</updated>

		<summary type="html">&lt;p&gt;Ollehar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
Using &#039;&#039;&#039;JLog&#039;&#039;&#039; can be very useful in components when analysing the performance of custom extensions - or analysing where extensions are giving issues. Note this should be used in tandem with php exceptions - not as a replacement. See [[S:MyLanguage/Exceptions and Logging in Joomla 1.7 and Joomla Platform 11.1|Exceptions and Logging in Joomla 1.7 and Joomla Platform 11.1]] for more information on this.&amp;lt;/translate&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Calling the class == &amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
To use JLog you need to call the JLog class. Done through the following code:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    jimport(&#039;joomla.log.log&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Basic File Logging == &amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
Often you may wish to display an error log message and log to an error file. Joomla allows this natively through the &amp;lt;tt&amp;gt;JLog::add&amp;lt;/tt&amp;gt; function. For example:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::add(JText::_(&#039;JTEXT_ERROR_MESSAGE&#039;), JLog::WARNING, &#039;jerror&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
Adding the category of jerror means that this message will also be displayed to users. To only write to file you can easily drop that parameter and simply use:&amp;lt;/translate&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    JLog::add(JText::_(&#039;JTEXT_ERROR_MESSAGE&#039;), JLog::WARNING);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Logging a specific extension == &amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
Sometimes it may be useful to log the errors to a specific file. In this case you can.&amp;lt;/translate&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.errors.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets messages of all log levels to be sent to the file&lt;br /&gt;
        JLog::ALL,&lt;br /&gt;
        // The log category/categories which should be recorded in this file&lt;br /&gt;
        // In this case, it&#039;s just the one category from our extension, still&lt;br /&gt;
        // we need to put it inside an array&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
Now remember to change the category when you add a log message. Such as in the example below.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::add(JText::_(&#039;JTEXT_ERROR_MESSAGE&#039;), JLog::WARNING, &#039;com_helloworld&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; You may wish to combine this with the [[S:MyLanguage/Display error messages and notices|Display error messages and notices]] section to display visable error notifications to users.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Logging specific priorities == &amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
You can also add an additional logger to capture only critical and emergency log notifications:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.critical_emergency.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets critical and emergency log level messages to be sent to the file&lt;br /&gt;
        JLog::CRITICAL + JLog::EMERGENCY,&lt;br /&gt;
        // The log category which should be recorded in this file&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
You can also exclude a specific category from being included. For example, to log all but DEBUG messages:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.all_but_debug.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets all but DEBUG log level messages to be sent to the file&lt;br /&gt;
        JLog::ALL &amp;amp; ~JLog::DEBUG,&lt;br /&gt;
        // The log category which should be recorded in this file&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
Notice how &#039;&#039;&#039;bitwise&#039;&#039;&#039; operations (bitwise AND, &amp;amp;; and bitwise NOT, ~) are used to calculate the accepted log levels.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Formatting the logfile == &amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
The first parameter to addLogger can have a few optional additional settings in addition to the &amp;lt;tt&amp;gt;text_file&amp;lt;/tt&amp;gt; entry.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
There is for example the entry &amp;lt;tt&amp;gt;text_entry_format&amp;lt;/tt&amp;gt;, specifying the format of each line in your logfile.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
The default format is:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &#039;{DATETIME} {PRIORITY}      {CATEGORY}      {MESSAGE}&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
Here is an example of a different format which shows how to omit the category:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.critical_emergency.php&#039;,&lt;br /&gt;
             // Sets the format of each line&lt;br /&gt;
             &#039;text_entry_format&#039; =&amp;gt; &#039;{DATETIME} {PRIORITY} {MESSAGE}&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets all but DEBUG log level messages to be sent to the file&lt;br /&gt;
        JLog::ALL &amp;amp; ~JLog::DEBUG,&lt;br /&gt;
        // The log category which should be recorded in this file&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
In addition to the placeholders shown above in the default string, the following values are available:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    {CLIENTIP}&lt;br /&gt;
    {TIME}&lt;br /&gt;
    {DATE}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
There is an additional optional boolean parameter &amp;lt;tt&amp;gt;text_file_no_php&amp;lt;/tt&amp;gt;, which specifies whether the log file is prepended with the usual prefix of:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    #&lt;br /&gt;
    #&amp;lt;?php die(&#039;Forbidden.&#039;);?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Usually you should not set this setting to false. Log files should not be readable from the outside, since they can provide valuable information about your system for attackers.&lt;br /&gt;
Only dabble with this if you know what you&#039;re doing!&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
Furthermore, if you want to store the log file somewhere else than the logging path configured in the Joomla! settings, you can there is the &amp;lt;tt&amp;gt;text_file_path&amp;lt;/tt&amp;gt; setting.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Exceptions == &amp;lt;!--T:25--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:26--&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;JLog::add()&amp;lt;/code&amp;gt; will throw an exception if it can&#039;t write to the log file. To avoid this, you&#039;d have to implement your own logger class and then include it with:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Use mycustomlogger&lt;br /&gt;
             &#039;logger&#039; =&amp;gt; &#039;mycustomlogger&#039;,&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.errors.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        JLog::ALL,&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:24--&amp;gt;&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[category:Joomla! 1.7]]&lt;br /&gt;
[[category:Joomla! 2.5]]&lt;br /&gt;
[[category:Joomla! 3.0]]&lt;br /&gt;
[[category:Joomla! 3.x]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ollehar</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Using_JLog&amp;diff=453296</id>
		<title>Using JLog</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Using_JLog&amp;diff=453296"/>
		<updated>2017-10-20T12:08:03Z</updated>

		<summary type="html">&lt;p&gt;Ollehar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
Using &#039;&#039;&#039;JLog&#039;&#039;&#039; can be very useful in components when analysing the performance of custom extensions - or analysing where extensions are giving issues. Note this should be used in tandem with php exceptions - not as a replacement. See [[S:MyLanguage/Exceptions and Logging in Joomla 1.7 and Joomla Platform 11.1|Exceptions and Logging in Joomla 1.7 and Joomla Platform 11.1]] for more information on this.&amp;lt;/translate&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Calling the class == &amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
To use JLog you need to call the JLog class. Done through the following code:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    jimport(&#039;joomla.log.log&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Basic File Logging == &amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
Often you may wish to display an error log message and log to an error file. Joomla allows this natively through the &amp;lt;tt&amp;gt;JLog::add&amp;lt;/tt&amp;gt; function. For example:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::add(JText::_(&#039;JTEXT_ERROR_MESSAGE&#039;), JLog::WARNING, &#039;jerror&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
Adding the category of jerror means that this message will also be displayed to users. To only write to file you can easily drop that parameter and simply use:&amp;lt;/translate&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    JLog::add(JText::_(&#039;JTEXT_ERROR_MESSAGE&#039;), JLog::WARNING);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Logging a specific extension == &amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
Sometimes it may be useful to log the errors to a specific file. In this case you can.&amp;lt;/translate&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.errors.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets messages of all log levels to be sent to the file&lt;br /&gt;
        JLog::ALL,&lt;br /&gt;
        // The log category/categories which should be recorded in this file&lt;br /&gt;
        // In this case, it&#039;s just the one category from our extension, still&lt;br /&gt;
        // we need to put it inside an array&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
Now remember to change the category when you add a log message. Such as in the example below.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::add(JText::_(&#039;JTEXT_ERROR_MESSAGE&#039;), JLog::WARNING, &#039;com_helloworld&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; You may wish to combine this with the [[S:MyLanguage/Display error messages and notices|Display error messages and notices]] section to display visable error notifications to users.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Logging specific priorities == &amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
You can also add an additional logger to capture only critical and emergency log notifications:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.critical_emergency.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets critical and emergency log level messages to be sent to the file&lt;br /&gt;
        JLog::CRITICAL + JLog::EMERGENCY,&lt;br /&gt;
        // The log category which should be recorded in this file&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
You can also exclude a specific category from being included. For example, to log all but DEBUG messages:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.all_but_debug.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets all but DEBUG log level messages to be sent to the file&lt;br /&gt;
        JLog::ALL &amp;amp; ~JLog::DEBUG,&lt;br /&gt;
        // The log category which should be recorded in this file&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
Notice how &#039;&#039;&#039;bitwise&#039;&#039;&#039; operations (bitwise AND, &amp;amp;; and bitwise NOT, ~) are used to calculate the accepted log levels.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Formatting the logfile == &amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
The first parameter to addLogger can have a few optional additional settings in addition to the &amp;lt;tt&amp;gt;text_file&amp;lt;/tt&amp;gt; entry.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
There is for example the entry &amp;lt;tt&amp;gt;text_entry_format&amp;lt;/tt&amp;gt;, specifying the format of each line in your logfile.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
The default format is:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &#039;{DATETIME} {PRIORITY}      {CATEGORY}      {MESSAGE}&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
Here is an example of a different format which shows how to omit the category:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.critical_emergency.php&#039;,&lt;br /&gt;
             // Sets the format of each line&lt;br /&gt;
             &#039;text_entry_format&#039; =&amp;gt; &#039;{DATETIME} {PRIORITY} {MESSAGE}&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets all but DEBUG log level messages to be sent to the file&lt;br /&gt;
        JLog::ALL &amp;amp; ~JLog::DEBUG,&lt;br /&gt;
        // The log category which should be recorded in this file&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
In addition to the placeholders shown above in the default string, the following values are available:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    {CLIENTIP}&lt;br /&gt;
    {TIME}&lt;br /&gt;
    {DATE}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
There is an additional optional boolean parameter &amp;lt;tt&amp;gt;text_file_no_php&amp;lt;/tt&amp;gt;, which specifies whether the log file is prepended with the usual prefix of:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    #&lt;br /&gt;
    #&amp;lt;?php die(&#039;Forbidden.&#039;);?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Usually you should not set this setting to false. Log files should not be readable from the outside, since they can provide valuable information about your system for attackers.&lt;br /&gt;
Only dabble with this if you know what you&#039;re doing!&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
Furthermore, if you want to store the log file somewhere else than the logging path configured in the Joomla! settings, you can there is the &amp;lt;tt&amp;gt;text_file_path&amp;lt;/tt&amp;gt; setting.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Exceptions == &amp;lt;!--T:25--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:26--&amp;gt;&lt;br /&gt;
JLog::add() will throw an exception if it can&#039;t write to the log file. To avoid this, you&#039;d have to implement your own logger class and then include it with:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Use mycustomlogger&lt;br /&gt;
             &#039;logger&#039; =&amp;gt; &#039;mycustomlogger&#039;,&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.errors.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        JLog::ALL,&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:24--&amp;gt;&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[category:Joomla! 1.7]]&lt;br /&gt;
[[category:Joomla! 2.5]]&lt;br /&gt;
[[category:Joomla! 3.0]]&lt;br /&gt;
[[category:Joomla! 3.x]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ollehar</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Using_JLog&amp;diff=453295</id>
		<title>Using JLog</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Using_JLog&amp;diff=453295"/>
		<updated>2017-10-20T12:07:36Z</updated>

		<summary type="html">&lt;p&gt;Ollehar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
Using &#039;&#039;&#039;JLog&#039;&#039;&#039; can be very useful in components when analysing the performance of custom extensions - or analysing where extensions are giving issues. Note this should be used in tandem with php exceptions - not as a replacement. See [[S:MyLanguage/Exceptions and Logging in Joomla 1.7 and Joomla Platform 11.1|Exceptions and Logging in Joomla 1.7 and Joomla Platform 11.1]] for more information on this.&amp;lt;/translate&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Calling the class == &amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
To use JLog you need to call the JLog class. Done through the following code:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    jimport(&#039;joomla.log.log&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Basic File Logging == &amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
Often you may wish to display an error log message and log to an error file. Joomla allows this natively through the &amp;lt;tt&amp;gt;JLog::add&amp;lt;/tt&amp;gt; function. For example:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::add(JText::_(&#039;JTEXT_ERROR_MESSAGE&#039;), JLog::WARNING, &#039;jerror&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
Adding the category of jerror means that this message will also be displayed to users. To only write to file you can easily drop that parameter and simply use:&amp;lt;/translate&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    JLog::add(JText::_(&#039;JTEXT_ERROR_MESSAGE&#039;), JLog::WARNING);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Logging a specific extension == &amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
Sometimes it may be useful to log the errors to a specific file. In this case you can.&amp;lt;/translate&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.errors.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets messages of all log levels to be sent to the file&lt;br /&gt;
        JLog::ALL,&lt;br /&gt;
        // The log category/categories which should be recorded in this file&lt;br /&gt;
        // In this case, it&#039;s just the one category from our extension, still&lt;br /&gt;
        // we need to put it inside an array&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
Now remember to change the category when you add a log message. Such as in the example below.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::add(JText::_(&#039;JTEXT_ERROR_MESSAGE&#039;), JLog::WARNING, &#039;com_helloworld&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; You may wish to combine this with the [[S:MyLanguage/Display error messages and notices|Display error messages and notices]] section to display visable error notifications to users.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Logging specific priorities == &amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
You can also add an additional logger to capture only critical and emergency log notifications:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.critical_emergency.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets critical and emergency log level messages to be sent to the file&lt;br /&gt;
        JLog::CRITICAL + JLog::EMERGENCY,&lt;br /&gt;
        // The log category which should be recorded in this file&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
You can also exclude a specific category from being included. For example, to log all but DEBUG messages:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.all_but_debug.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets all but DEBUG log level messages to be sent to the file&lt;br /&gt;
        JLog::ALL &amp;amp; ~JLog::DEBUG,&lt;br /&gt;
        // The log category which should be recorded in this file&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
Notice how &#039;&#039;&#039;bitwise&#039;&#039;&#039; operations (bitwise AND, &amp;amp;; and bitwise NOT, ~) are used to calculate the accepted log levels.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Formatting the logfile == &amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
The first parameter to addLogger can have a few optional additional settings in addition to the &amp;lt;tt&amp;gt;text_file&amp;lt;/tt&amp;gt; entry.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
There is for example the entry &amp;lt;tt&amp;gt;text_entry_format&amp;lt;/tt&amp;gt;, specifying the format of each line in your logfile.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
The default format is:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &#039;{DATETIME} {PRIORITY}      {CATEGORY}      {MESSAGE}&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
Here is an example of a different format which shows how to omit the category:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.critical_emergency.php&#039;,&lt;br /&gt;
             // Sets the format of each line&lt;br /&gt;
             &#039;text_entry_format&#039; =&amp;gt; &#039;{DATETIME} {PRIORITY} {MESSAGE}&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets all but DEBUG log level messages to be sent to the file&lt;br /&gt;
        JLog::ALL &amp;amp; ~JLog::DEBUG,&lt;br /&gt;
        // The log category which should be recorded in this file&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
In addition to the placeholders shown above in the default string, the following values are available:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    {CLIENTIP}&lt;br /&gt;
    {TIME}&lt;br /&gt;
    {DATE}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
There is an additional optional boolean parameter &amp;lt;tt&amp;gt;text_file_no_php&amp;lt;/tt&amp;gt;, which specifies whether the log file is prepended with the usual prefix of:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    #&lt;br /&gt;
    #&amp;lt;?php die(&#039;Forbidden.&#039;);?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Usually you should not set this setting to false. Log files should not be readable from the outside, since they can provide valuable information about your system for attackers.&lt;br /&gt;
Only dabble with this if you know what you&#039;re doing!&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
Furthermore, if you want to store the log file somewhere else than the logging path configured in the Joomla! settings, you can there is the &amp;lt;tt&amp;gt;text_file_path&amp;lt;/tt&amp;gt; setting.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:24--&amp;gt;&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[category:Joomla! 1.7]]&lt;br /&gt;
[[category:Joomla! 2.5]]&lt;br /&gt;
[[category:Joomla! 3.0]]&lt;br /&gt;
[[category:Joomla! 3.x]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Exceptions == &amp;lt;!--T:25--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:26--&amp;gt;&lt;br /&gt;
JLog::add() will throw an exception if it can&#039;t write to the log file. To avoid this, you&#039;d have to implement your own logger class and then include it with:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Use mycustomlogger&lt;br /&gt;
             &#039;logger&#039; =&amp;gt; &#039;mycustomlogger&#039;,&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.errors.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        JLog::ALL,&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;/div&gt;</summary>
		<author><name>Ollehar</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Using_JLog&amp;diff=453294</id>
		<title>Using JLog</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Using_JLog&amp;diff=453294"/>
		<updated>2017-10-20T12:06:31Z</updated>

		<summary type="html">&lt;p&gt;Ollehar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
Using &#039;&#039;&#039;JLog&#039;&#039;&#039; can be very useful in components when analysing the performance of custom extensions - or analysing where extensions are giving issues. Note this should be used in tandem with php exceptions - not as a replacement. See [[S:MyLanguage/Exceptions and Logging in Joomla 1.7 and Joomla Platform 11.1|Exceptions and Logging in Joomla 1.7 and Joomla Platform 11.1]] for more information on this.&amp;lt;/translate&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Calling the class == &amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
To use JLog you need to call the JLog class. Done through the following code:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    jimport(&#039;joomla.log.log&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Basic File Logging == &amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
Often you may wish to display an error log message and log to an error file. Joomla allows this natively through the &amp;lt;tt&amp;gt;JLog::add&amp;lt;/tt&amp;gt; function. For example:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::add(JText::_(&#039;JTEXT_ERROR_MESSAGE&#039;), JLog::WARNING, &#039;jerror&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
Adding the category of jerror means that this message will also be displayed to users. To only write to file you can easily drop that parameter and simply use:&amp;lt;/translate&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    JLog::add(JText::_(&#039;JTEXT_ERROR_MESSAGE&#039;), JLog::WARNING);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Logging a specific extension == &amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
Sometimes it may be useful to log the errors to a specific file. In this case you can.&amp;lt;/translate&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.errors.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets messages of all log levels to be sent to the file&lt;br /&gt;
        JLog::ALL,&lt;br /&gt;
        // The log category/categories which should be recorded in this file&lt;br /&gt;
        // In this case, it&#039;s just the one category from our extension, still&lt;br /&gt;
        // we need to put it inside an array&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
Now remember to change the category when you add a log message. Such as in the example below.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::add(JText::_(&#039;JTEXT_ERROR_MESSAGE&#039;), JLog::WARNING, &#039;com_helloworld&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; You may wish to combine this with the [[S:MyLanguage/Display error messages and notices|Display error messages and notices]] section to display visable error notifications to users.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Logging specific priorities == &amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
You can also add an additional logger to capture only critical and emergency log notifications:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.critical_emergency.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets critical and emergency log level messages to be sent to the file&lt;br /&gt;
        JLog::CRITICAL + JLog::EMERGENCY,&lt;br /&gt;
        // The log category which should be recorded in this file&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
You can also exclude a specific category from being included. For example, to log all but DEBUG messages:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.all_but_debug.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets all but DEBUG log level messages to be sent to the file&lt;br /&gt;
        JLog::ALL &amp;amp; ~JLog::DEBUG,&lt;br /&gt;
        // The log category which should be recorded in this file&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
Notice how &#039;&#039;&#039;bitwise&#039;&#039;&#039; operations (bitwise AND, &amp;amp;; and bitwise NOT, ~) are used to calculate the accepted log levels.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Formatting the logfile == &amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
The first parameter to addLogger can have a few optional additional settings in addition to the &amp;lt;tt&amp;gt;text_file&amp;lt;/tt&amp;gt; entry.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
There is for example the entry &amp;lt;tt&amp;gt;text_entry_format&amp;lt;/tt&amp;gt;, specifying the format of each line in your logfile.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
The default format is:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &#039;{DATETIME} {PRIORITY}      {CATEGORY}      {MESSAGE}&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
Here is an example of a different format which shows how to omit the category:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.critical_emergency.php&#039;,&lt;br /&gt;
             // Sets the format of each line&lt;br /&gt;
             &#039;text_entry_format&#039; =&amp;gt; &#039;{DATETIME} {PRIORITY} {MESSAGE}&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets all but DEBUG log level messages to be sent to the file&lt;br /&gt;
        JLog::ALL &amp;amp; ~JLog::DEBUG,&lt;br /&gt;
        // The log category which should be recorded in this file&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
In addition to the placeholders shown above in the default string, the following values are available:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    {CLIENTIP}&lt;br /&gt;
    {TIME}&lt;br /&gt;
    {DATE}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
There is an additional optional boolean parameter &amp;lt;tt&amp;gt;text_file_no_php&amp;lt;/tt&amp;gt;, which specifies whether the log file is prepended with the usual prefix of:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    #&lt;br /&gt;
    #&amp;lt;?php die(&#039;Forbidden.&#039;);?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Usually you should not set this setting to false. Log files should not be readable from the outside, since they can provide valuable information about your system for attackers.&lt;br /&gt;
Only dabble with this if you know what you&#039;re doing!&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
Furthermore, if you want to store the log file somewhere else than the logging path configured in the Joomla! settings, you can there is the &amp;lt;tt&amp;gt;text_file_path&amp;lt;/tt&amp;gt; setting.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:24--&amp;gt;&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[category:Joomla! 1.7]]&lt;br /&gt;
[[category:Joomla! 2.5]]&lt;br /&gt;
[[category:Joomla! 3.0]]&lt;br /&gt;
[[category:Joomla! 3.x]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Exceptions == &amp;lt;!--T:25--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
JLog::add() will throw an exception if it can&#039;t write to the log file. To avoid this, you&#039;d have to implement your own logger class and then include it with&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Use mycustomlogger&lt;br /&gt;
             &#039;logger&#039; =&amp;gt; &#039;mycustomlogger&#039;,&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.errors.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        JLog::ALL,&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;/div&gt;</summary>
		<author><name>Ollehar</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Using_JLog&amp;diff=453289</id>
		<title>Using JLog</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Using_JLog&amp;diff=453289"/>
		<updated>2017-10-20T10:58:13Z</updated>

		<summary type="html">&lt;p&gt;Ollehar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
Using &#039;&#039;&#039;JLog&#039;&#039;&#039; can be very useful in components when analysing the performance of custom extensions - or analysing where extensions are giving issues. Note this should be used in tandem with php exceptions - not as a replacement. See [[S:MyLanguage/Exceptions and Logging in Joomla 1.7 and Joomla Platform 11.1|Exceptions and Logging in Joomla 1.7 and Joomla Platform 11.1]] for more information on this.&amp;lt;/translate&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Calling the class == &amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
To use JLog you need to call the JLog class. Done through the following code:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    jimport(&#039;joomla.log.log&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Basic File Logging == &amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
Often you may wish to display an error log message and log to an error file. Joomla allows this natively through the &amp;lt;tt&amp;gt;JLog::add&amp;lt;/tt&amp;gt; function. For example:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::add(JText::_(&#039;JTEXT_ERROR_MESSAGE&#039;), JLog::WARNING, &#039;jerror&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
Adding the category of jerror means that this message will also be displayed to users. To only write to file you can easily drop that parameter and simply use:&amp;lt;/translate&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    JLog::add(JText::_(&#039;JTEXT_ERROR_MESSAGE&#039;), JLog::WARNING);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Logging a specific extension == &amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
Sometimes it may be useful to log the errors to a specific file. In this case you can.&amp;lt;/translate&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.errors.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets messages of all log levels to be sent to the file&lt;br /&gt;
        JLog::ALL,&lt;br /&gt;
        // The log category/categories which should be recorded in this file&lt;br /&gt;
        // In this case, it&#039;s just the one category from our extension, still&lt;br /&gt;
        // we need to put it inside an array&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
Now remember to change the category when you add a log message. Such as in the example below.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::add(JText::_(&#039;JTEXT_ERROR_MESSAGE&#039;), JLog::WARNING, &#039;com_helloworld&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; You may wish to combine this with the [[S:MyLanguage/Display error messages and notices|Display error messages and notices]] section to display visable error notifications to users.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Logging specific priorities == &amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
You can also add an additional logger to capture only critical and emergency log notifications:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.critical_emergency.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets critical and emergency log level messages to be sent to the file&lt;br /&gt;
        JLog::CRITICAL + JLog::EMERGENCY,&lt;br /&gt;
        // The log category which should be recorded in this file&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
You can also exclude a specific category from being included. For example, to log all but DEBUG messages:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.all_but_debug.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets all but DEBUG log level messages to be sent to the file&lt;br /&gt;
        JLog::ALL &amp;amp; ~JLog::DEBUG,&lt;br /&gt;
        // The log category which should be recorded in this file&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
Notice how &#039;&#039;&#039;bitwise&#039;&#039;&#039; operations (bitwise AND, &amp;amp;; and bitwise NOT, ~) are used to calculate the accepted log levels.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Formatting the logfile == &amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
The first parameter to addLogger can have a few optional additional settings in addition to the &amp;lt;tt&amp;gt;text_file&amp;lt;/tt&amp;gt; entry.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
There is for example the entry &amp;lt;tt&amp;gt;text_entry_format&amp;lt;/tt&amp;gt;, specifying the format of each line in your logfile.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
The default format is:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &#039;{DATETIME} {PRIORITY}      {CATEGORY}      {MESSAGE}&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
Here is an example of a different format which shows how to omit the category:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Sets file name&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.critical_emergency.php&#039;,&lt;br /&gt;
             // Sets the format of each line&lt;br /&gt;
             &#039;text_entry_format&#039; =&amp;gt; &#039;{DATETIME} {PRIORITY} {MESSAGE}&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        // Sets all but DEBUG log level messages to be sent to the file&lt;br /&gt;
        JLog::ALL &amp;amp; ~JLog::DEBUG,&lt;br /&gt;
        // The log category which should be recorded in this file&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
In addition to the placeholders shown above in the default string, the following values are available:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    {CLIENTIP}&lt;br /&gt;
    {TIME}&lt;br /&gt;
    {DATE}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
There is an additional optional boolean parameter &amp;lt;tt&amp;gt;text_file_no_php&amp;lt;/tt&amp;gt;, which specifies whether the log file is prepended with the usual prefix of:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    #&lt;br /&gt;
    #&amp;lt;?php die(&#039;Forbidden.&#039;);?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Usually you should not set this setting to false. Log files should not be readable from the outside, since they can provide valuable information about your system for attackers.&lt;br /&gt;
Only dabble with this if you know what you&#039;re doing!&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
Furthermore, if you want to store the log file somewhere else than the logging path configured in the Joomla! settings, you can there is the &amp;lt;tt&amp;gt;text_file_path&amp;lt;/tt&amp;gt; setting.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:24--&amp;gt;&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[category:Joomla! 1.7]]&lt;br /&gt;
[[category:Joomla! 2.5]]&lt;br /&gt;
[[category:Joomla! 3.0]]&lt;br /&gt;
[[category:Joomla! 3.x]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Exceptions == &amp;lt;!--T:25--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
JLog::add() will throw an exception if it can&#039;t write to the log file. To avoid this, you&#039;d have to implement your own logger class and then include it with&lt;br /&gt;
&lt;br /&gt;
    JLog::addLogger(&lt;br /&gt;
        array(&lt;br /&gt;
             // Use mycustomlogger&lt;br /&gt;
             &#039;logger&#039; =&amp;gt; &#039;mycustomlogger&#039;,&lt;br /&gt;
             &#039;text_file&#039; =&amp;gt; &#039;com_helloworld.errors.php&#039;&lt;br /&gt;
        ),&lt;br /&gt;
        JLog::ALL,&lt;br /&gt;
        array(&#039;com_helloworld&#039;)&lt;br /&gt;
    );&lt;/div&gt;</summary>
		<author><name>Ollehar</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Ollehar&amp;diff=453288</id>
		<title>User:Ollehar</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Ollehar&amp;diff=453288"/>
		<updated>2017-10-20T10:49:24Z</updated>

		<summary type="html">&lt;p&gt;Ollehar: Created page with &amp;quot;Hi,  My name is Olle Haerstedt. I work for LimeSurvey GmbH in Hamburg.&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hi,&lt;br /&gt;
&lt;br /&gt;
My name is Olle Haerstedt. I work for LimeSurvey GmbH in Hamburg.&lt;/div&gt;</summary>
		<author><name>Ollehar</name></author>
	</entry>
</feed>