Hi Christian,

This is my config file:

<log4php:configuration xmlns:log4php="http://logging.apache.org/log4php/";>
    <appender name="default" class="LoggerAppenderDailyFile">
        <param name="file" value="logs/%s.log" />
        <param name="datePattern" value="Ymd" />
        <layout class="LoggerLayoutPattern">
            <param name="ConversionPattern" value="%d{Y-m-d H:i:s} [%p] %c:
%m* (%F at %L)*" />
        </layout>
    </appender>

        <root>
            <level value="DEBUG" />
            <appender_ref ref="default" />
        </root>

    </log4php:configuration>

The bold characters are responsible for filename in log file. As it called
from loggerimplementation.php.
So, it always show its name, but the real file used loggerimplementation as
wrapper. So, i want to know , is there any way i can define thing like %F so
that i can get real file name.

--
Mohit

On Fri, Jun 10, 2011 at 5:07 PM, Mohit Srivastava <
[email protected]> wrote:

> <?php
>
> /*
> Looger.php is included.
> */
> require_once('log4php/Logger.php');
> /*
> This class is use to generate a log file.
> */
> class Loggerimplementation extends Exception{
> /*
>  Member for logger Object.
> */
>     private $loggerObj;
>
> /*
>  Member for caller class ie class called loggerImplementation class.
> */
>     private $callerClass;
> /*
> Constructor intialize the member caller class.
> Also configure it with config.xml.
> */
>     public function __construct($ClassName) {
>        $this->callerClass=$ClassName;
>        if($this->callerClass==NULL)
>             throw new NullValueException('Caller Class Value is NULL');
>
>        $loggerConfig = 'log4php/xml/config.xml';
>         Logger::configure($loggerConfig);
>
>         $this->loggerObj = Logger::getLogger($this->callerClass);
>
>         if($this->loggerObj==NULL)
>             throw new NullValueException('Logger Object Created is NULL');
>     }
> /*
> Constructor intialize the member caller class.
> Also configure it with anotherconfig.xml. This constructor is used for
> warn, fatal,error cases.
> */
>     public function __constructlevel($ClassName,$isErrSet) {
>        if($isErrSet)
>         {
>             $this->callerClass=ClassName;
>             if($this->callerClass==NULL)
>                 throw new NullValueException('Caller Class Value is NULL');
>
>             $loggerConfig = 'log4php/xml/config.xml';
>             Logger::configure($loggerConfig);
>
>             $this->loggerObj = Logger::getLogger($this->callerClass);
>             if($this->loggerObj==NULL)
>                 throw new NullValueException('Logger Object Created is
> NULL');
>         }
>         else
>         {
>             throw new UnexpectedValueException("isErrSet value is wrong");
>             }
>     }
> /*
> function used to generate log message. In this , level will be check as it
> passed as parameter according to which a log file is generated.
> */
>     public function logMessage($message,$level)
>     {
>
>         if($message=="null")
>             throw new NullValueException("message cant be null");
>
>         if($level!="INFO" && $level!="DEBUG" && $level!="WARN" &&
> $level!="ERROR" && $level!="FATAL")
>             throw new UnexpectedValueException("Invalid value of Log
> Level");
>         if($level=="DEBUG")
>             $this->loggerObj->debug($message);
>         else
>             if($level=="INFO")
>             $this->loggerObj->info($message);
>         else
>             if($level=="WARN")
>             $this->loggerObj->warn($message);
>         else
>             if($level=="ERROR")
>             $this->loggerObj->error($message);
>         else
>             if($level=="FATAL")
>             $this->loggerObj->fatal($message);
>     }
> }
>
>
> ?>
>
> this is my wrapper.
>
>
>
> On Fri, Jun 10, 2011 at 4:35 PM, Christian Grobmeier 
> <[email protected]>wrote:
>
>> Hi,
>>
>> can you show us the Logging code?
>>
>> Esspecially the Logger::getLogger code is of interest.
>>
>> Thanks
>> Christian
>>
>> On Fri, Jun 10, 2011 at 12:53 PM, Mohit Srivastava
>> <[email protected]> wrote:
>> > Hi all,
>> >
>> > I write a wrapper over log4php api named as loggerimplementation.php
>> >
>> > Now i faced a problem in log files. When i called a function for logging
>> > defined in loggerimplementation.
>> >
>> > Log file generated as:
>> >
>> > 2011-06-10 10:49:17 [INFO] Log4phpTest: Hello (at
>> > C:\xampp\htdocs\logger\Loggerimplementation.php line 74)
>> > 2011-06-10 10:50:08 [INFO] Log4phpTest: Hello (at
>> > C:\xampp\htdocs\logger\Loggerimplementation.php line 74)
>> > 2011-06-10 11:04:01 [INFO] Log4phpTest: Hello (at
>> > C:\xampp\htdocs\logger\Loggerimplementation.php line 78)
>> >
>> > Now , as you can see %F will always show wrapper file name coz it always
>> > called from there. But I want real file name which one used this
>> wrapper.
>> >
>> > So please suggest me the way for this.
>> >
>> > Or
>> > tell me from where %F details i can get?
>> >
>> > Waiting for reply.
>> >
>> > --
>> > Mohit
>> >
>>
>>
>>
>> --
>> http://www.grobmeier.de
>>
>
>

Reply via email to