Convert to array from XML

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Convert to array from XML

Michael Sole-2

We are using log4php quite extensively in our application. We began by using the XML config file but found that too much of a hassle as we end up with lots of them. The array method of configuring loggers seems much more efficient but I am having difficulty converting our xml file to the array. I am sadly not able to find a good enough example to use as a template. Can someone please help me by converting this XML into an array?

 

<log4php:configuration xmlns:log4php="http://logging.apache.org/log4php/">

    <appender name="myAppender" class="LoggerAppenderDailyFile">      

                <layout class="LoggerLayoutTTCC" />

    <param name="datePattern" value="Y-m-d" />

        <param name="file" value="/var/www/virtual/derver.net/michael/htdocs/log/michaeldev%s.log" />

    </appender>

                <appender name="myAppender" class="LoggerAppenderEcho">

    <layout class="LoggerLayoutTTCC" />

</appender>

    <root>

        <level value="WARN" />

        <appender_ref ref="myAppender" />

    </root>

</log4php:configuration>

 

Also, I have had trouble (in the past) with relative paths in the XML, I assume the array method won’t have these issues?

_______________

Michael F. Sole
[hidden email]

Office: 732.632.8801, ext. 261
Mobile: 516.592.3683

Fax: 732.632.3599

Gold Mobile
www.gold-mobile.com  

Mobile Health Tech Group
www.mobilehealthtech.md

This e-mail and any files transmitted are intended solely for the use of the individual or entity to whom they are addressed, and for the use of Gold Mobile.  Any other use is strictly prohibited.

 

Reply | Threaded
Open this post in threaded view
|

Re: Convert to array from XML

Christian grobmeier
On Tue, May 15, 2012 at 7:34 PM, Michael Sole <[hidden email]> wrote:
> We are using log4php quite extensively in our application. We began by using
> the XML config file but found that too much of a hassle as we end up with
> lots of them. The array method of configuring loggers seems much more
> efficient but I am having difficulty converting our xml file to the array. I
> am sadly not able to find a good enough example to use as a template. Can
> someone please help me by converting this XML into an array?

Have you seen that for each component is an example for xml and php
(array) available?
F.e. http://logging.apache.org/log4php/docs/appenders/rolling-file.html

A quick start for php configuration:
http://logging.apache.org/log4php/docs/configuration.html

HTH
Christian

>
>
>
> <log4php:configuration xmlns:log4php="http://logging.apache.org/log4php/">
>
>     <appender name="myAppender" class="LoggerAppenderDailyFile">
>
>                 <layout class="LoggerLayoutTTCC" />
>
>     <param name="datePattern" value="Y-m-d" />
>
>         <param name="file"
> value="/var/www/virtual/derver.net/michael/htdocs/log/michaeldev%s.log" />
>
>     </appender>
>
>                 <appender name="myAppender" class="LoggerAppenderEcho">
>
>     <layout class="LoggerLayoutTTCC" />
>
> </appender>
>
>     <root>
>
>         <level value="WARN" />
>
>         <appender_ref ref="myAppender" />
>
>     </root>
>
> </log4php:configuration>
>
>
>
> Also, I have had trouble (in the past) with relative paths in the XML, I
> assume the array method won’t have these issues?
>
> _______________
>
> Michael F. Sole
> [hidden email]
>
> Office: 732.632.8801, ext. 261
> Mobile: 516.592.3683
>
> Fax: 732.632.3599
>
> Gold Mobile
> www.gold-mobile.com
>
> Mobile Health Tech Group
> www.mobilehealthtech.md
>
> This e-mail and any files transmitted are intended solely for the use of the
> individual or entity to whom they are addressed, and for the use of Gold
> Mobile.  Any other use is strictly prohibited.
>
>



--
http://www.grobmeier.de
https://www.timeandbill.de
Reply | Threaded
Open this post in threaded view
|

RE: Convert to array from XML

Michael Sole-2
Thanks, I didn't see that first example. It appears to be helpful.  I tried to xml converter and found 2 problems, 1 it didn't work with the auto loader (I installed as a pear plugin) and 2 it didn't appear to get all the settings from the XML. Here is the output from the XML below:

Array
(
    [appenders] => Array
        (
            [myAppender] => Array
                (
                    [class] => LoggerAppenderEcho
                    [layout] => Array
                        (
                            [class] => LoggerLayoutTTCC
                        )

                )

        )

    [loggers] => Array
        (
        )

    [renderers] => Array
        (
        )

    [rootLogger] => Array
        (
            [level] => WARN
            [appenders] => Array
                (
                    [0] => myAppender
                )

        )

)

-----Original Message-----
From: Christian Grobmeier [mailto:[hidden email]]
Sent: Tuesday, May 15, 2012 1:51 PM
To: Log4PHP User
Subject: Re: Convert to array from XML

On Tue, May 15, 2012 at 7:34 PM, Michael Sole <[hidden email]> wrote:
> We are using log4php quite extensively in our application. We began by
> using the XML config file but found that too much of a hassle as we
> end up with lots of them. The array method of configuring loggers
> seems much more efficient but I am having difficulty converting our
> xml file to the array. I am sadly not able to find a good enough
> example to use as a template. Can someone please help me by converting this XML into an array?

Have you seen that for each component is an example for xml and php
(array) available?
F.e. http://logging.apache.org/log4php/docs/appenders/rolling-file.html

A quick start for php configuration:
http://logging.apache.org/log4php/docs/configuration.html

HTH
Christian

>
>
>
> <log4php:configuration
> xmlns:log4php="http://logging.apache.org/log4php/">
>
>     <appender name="myAppender" class="LoggerAppenderDailyFile">
>
>                 <layout class="LoggerLayoutTTCC" />
>
>     <param name="datePattern" value="Y-m-d" />
>
>         <param name="file"
> value="/var/www/virtual/derver.net/michael/htdocs/log/michaeldev%s.log
> " />
>
>     </appender>
>
>                 <appender name="myAppender"
> class="LoggerAppenderEcho">
>
>     <layout class="LoggerLayoutTTCC" />
>
> </appender>
>
>     <root>
>
>         <level value="WARN" />
>
>         <appender_ref ref="myAppender" />
>
>     </root>
>
> </log4php:configuration>
>
>
>
> Also, I have had trouble (in the past) with relative paths in the XML,
> I assume the array method won’t have these issues?
>
> _______________
>
> Michael F. Sole
> [hidden email]
>
> Office: 732.632.8801, ext. 261
> Mobile: 516.592.3683
>
> Fax: 732.632.3599
>
> Gold Mobile
> www.gold-mobile.com
>
> Mobile Health Tech Group
> www.mobilehealthtech.md
>
> This e-mail and any files transmitted are intended solely for the use
> of the individual or entity to whom they are addressed, and for the
> use of Gold Mobile.  Any other use is strictly prohibited.
>
>



--
http://www.grobmeier.de
https://www.timeandbill.de
Reply | Threaded
Open this post in threaded view
|

RE: Convert to array from XML

Michael Sole-2
In reply to this post by Christian grobmeier
Christian,

As I mentioned before I switched from using the log4php as a subfolder to having it be a pear extension but I am getting a class not found unless I purposefully include that path in my script. Should it load automatically?

Mike

-----Original Message-----
From: Christian Grobmeier [mailto:[hidden email]]
Sent: Tuesday, May 15, 2012 1:51 PM
To: Log4PHP User
Subject: Re: Convert to array from XML

On Tue, May 15, 2012 at 7:34 PM, Michael Sole <[hidden email]> wrote:
> We are using log4php quite extensively in our application. We began by
> using the XML config file but found that too much of a hassle as we
> end up with lots of them. The array method of configuring loggers
> seems much more efficient but I am having difficulty converting our
> xml file to the array. I am sadly not able to find a good enough
> example to use as a template. Can someone please help me by converting this XML into an array?

Have you seen that for each component is an example for xml and php
(array) available?
F.e. http://logging.apache.org/log4php/docs/appenders/rolling-file.html

A quick start for php configuration:
http://logging.apache.org/log4php/docs/configuration.html

HTH
Christian

>
>
>
> <log4php:configuration
> xmlns:log4php="http://logging.apache.org/log4php/">
>
>     <appender name="myAppender" class="LoggerAppenderDailyFile">
>
>                 <layout class="LoggerLayoutTTCC" />
>
>     <param name="datePattern" value="Y-m-d" />
>
>         <param name="file"
> value="/var/www/virtual/derver.net/michael/htdocs/log/michaeldev%s.log
> " />
>
>     </appender>
>
>                 <appender name="myAppender"
> class="LoggerAppenderEcho">
>
>     <layout class="LoggerLayoutTTCC" />
>
> </appender>
>
>     <root>
>
>         <level value="WARN" />
>
>         <appender_ref ref="myAppender" />
>
>     </root>
>
> </log4php:configuration>
>
>
>
> Also, I have had trouble (in the past) with relative paths in the XML,
> I assume the array method won’t have these issues?
>
> _______________
>
> Michael F. Sole
> [hidden email]
>
> Office: 732.632.8801, ext. 261
> Mobile: 516.592.3683
>
> Fax: 732.632.3599
>
> Gold Mobile
> www.gold-mobile.com
>
> Mobile Health Tech Group
> www.mobilehealthtech.md
>
> This e-mail and any files transmitted are intended solely for the use
> of the individual or entity to whom they are addressed, and for the
> use of Gold Mobile.  Any other use is strictly prohibited.
>
>



--
http://www.grobmeier.de
https://www.timeandbill.de
Reply | Threaded
Open this post in threaded view
|

Re: Convert to array from XML

Christian grobmeier
On Tue, May 15, 2012 at 8:11 PM, Michael Sole <[hidden email]> wrote:
> Christian,
>
> As I mentioned before I switched from using the log4php as a subfolder to having it be a pear extension but I am getting a class not found unless I purposefully include that path in my script. Should it load automatically?

I am not a pear expert, but my expectation is it should load
automatically. Can you show us your folder structure?

Cheers

> Mike
>
> -----Original Message-----
> From: Christian Grobmeier [mailto:[hidden email]]
> Sent: Tuesday, May 15, 2012 1:51 PM
> To: Log4PHP User
> Subject: Re: Convert to array from XML
>
> On Tue, May 15, 2012 at 7:34 PM, Michael Sole <[hidden email]> wrote:
>> We are using log4php quite extensively in our application. We began by
>> using the XML config file but found that too much of a hassle as we
>> end up with lots of them. The array method of configuring loggers
>> seems much more efficient but I am having difficulty converting our
>> xml file to the array. I am sadly not able to find a good enough
>> example to use as a template. Can someone please help me by converting this XML into an array?
>
> Have you seen that for each component is an example for xml and php
> (array) available?
> F.e. http://logging.apache.org/log4php/docs/appenders/rolling-file.html
>
> A quick start for php configuration:
> http://logging.apache.org/log4php/docs/configuration.html
>
> HTH
> Christian
>
>>
>>
>>
>> <log4php:configuration
>> xmlns:log4php="http://logging.apache.org/log4php/">
>>
>>     <appender name="myAppender" class="LoggerAppenderDailyFile">
>>
>>                 <layout class="LoggerLayoutTTCC" />
>>
>>     <param name="datePattern" value="Y-m-d" />
>>
>>         <param name="file"
>> value="/var/www/virtual/derver.net/michael/htdocs/log/michaeldev%s.log
>> " />
>>
>>     </appender>
>>
>>                 <appender name="myAppender"
>> class="LoggerAppenderEcho">
>>
>>     <layout class="LoggerLayoutTTCC" />
>>
>> </appender>
>>
>>     <root>
>>
>>         <level value="WARN" />
>>
>>         <appender_ref ref="myAppender" />
>>
>>     </root>
>>
>> </log4php:configuration>
>>
>>
>>
>> Also, I have had trouble (in the past) with relative paths in the XML,
>> I assume the array method won’t have these issues?
>>
>> _______________
>>
>> Michael F. Sole
>> [hidden email]
>>
>> Office: 732.632.8801, ext. 261
>> Mobile: 516.592.3683
>>
>> Fax: 732.632.3599
>>
>> Gold Mobile
>> www.gold-mobile.com
>>
>> Mobile Health Tech Group
>> www.mobilehealthtech.md
>>
>> This e-mail and any files transmitted are intended solely for the use
>> of the individual or entity to whom they are addressed, and for the
>> use of Gold Mobile.  Any other use is strictly prohibited.
>>
>>
>
>
>
> --
> http://www.grobmeier.de
> https://www.timeandbill.de



--
http://www.grobmeier.de
https://www.timeandbill.de
Reply | Threaded
Open this post in threaded view
|

RE: Convert to array from XML

Michael Sole-2
Christian,

Miraculously it started working. I think I had to kill off all the php fcgi processes. I did restart apache but I guess a few processes needed to die.

Mike

-----Original Message-----
From: Christian Grobmeier [mailto:[hidden email]]
Sent: Tuesday, May 15, 2012 2:17 PM
To: Log4PHP User
Subject: Re: Convert to array from XML

On Tue, May 15, 2012 at 8:11 PM, Michael Sole <[hidden email]> wrote:
> Christian,
>
> As I mentioned before I switched from using the log4php as a subfolder to having it be a pear extension but I am getting a class not found unless I purposefully include that path in my script. Should it load automatically?

I am not a pear expert, but my expectation is it should load automatically. Can you show us your folder structure?

Cheers

> Mike
>
> -----Original Message-----
> From: Christian Grobmeier [mailto:[hidden email]]
> Sent: Tuesday, May 15, 2012 1:51 PM
> To: Log4PHP User
> Subject: Re: Convert to array from XML
>
> On Tue, May 15, 2012 at 7:34 PM, Michael Sole <[hidden email]> wrote:
>> We are using log4php quite extensively in our application. We began
>> by using the XML config file but found that too much of a hassle as
>> we end up with lots of them. The array method of configuring loggers
>> seems much more efficient but I am having difficulty converting our
>> xml file to the array. I am sadly not able to find a good enough
>> example to use as a template. Can someone please help me by converting this XML into an array?
>
> Have you seen that for each component is an example for xml and php
> (array) available?
> F.e.
> http://logging.apache.org/log4php/docs/appenders/rolling-file.html
>
> A quick start for php configuration:
> http://logging.apache.org/log4php/docs/configuration.html
>
> HTH
> Christian
>
>>
>>
>>
>> <log4php:configuration
>> xmlns:log4php="http://logging.apache.org/log4php/">
>>
>>     <appender name="myAppender" class="LoggerAppenderDailyFile">
>>
>>                 <layout class="LoggerLayoutTTCC" />
>>
>>     <param name="datePattern" value="Y-m-d" />
>>
>>         <param name="file"
>> value="/var/www/virtual/derver.net/michael/htdocs/log/michaeldev%s.lo
>> g
>> " />
>>
>>     </appender>
>>
>>                 <appender name="myAppender"
>> class="LoggerAppenderEcho">
>>
>>     <layout class="LoggerLayoutTTCC" />
>>
>> </appender>
>>
>>     <root>
>>
>>         <level value="WARN" />
>>
>>         <appender_ref ref="myAppender" />
>>
>>     </root>
>>
>> </log4php:configuration>
>>
>>
>>
>> Also, I have had trouble (in the past) with relative paths in the
>> XML, I assume the array method won’t have these issues?
>>
>> _______________
>>
>> Michael F. Sole
>> [hidden email]
>>
>> Office: 732.632.8801, ext. 261
>> Mobile: 516.592.3683
>>
>> Fax: 732.632.3599
>>
>> Gold Mobile
>> www.gold-mobile.com
>>
>> Mobile Health Tech Group
>> www.mobilehealthtech.md
>>
>> This e-mail and any files transmitted are intended solely for the use
>> of the individual or entity to whom they are addressed, and for the
>> use of Gold Mobile.  Any other use is strictly prohibited.
>>
>>
>
>
>
> --
> http://www.grobmeier.de
> https://www.timeandbill.de



--
http://www.grobmeier.de
https://www.timeandbill.de
Reply | Threaded
Open this post in threaded view
|

RE: Convert to array from XML

Michael Sole-2
In reply to this post by Christian grobmeier
Again, my apologies, I had the include in a file and forgot. It is, in fact, not autoloading.

As for the path, I installed it using pear install Apapche_log4php.

It puts it into this location:
include '/usr/share/php/log4php/Logger.php';

And again, sorry for the confusion.

-----Original Message-----
From: Christian Grobmeier [mailto:[hidden email]]
Sent: Tuesday, May 15, 2012 2:17 PM
To: Log4PHP User
Subject: Re: Convert to array from XML

On Tue, May 15, 2012 at 8:11 PM, Michael Sole <[hidden email]> wrote:
> Christian,
>
> As I mentioned before I switched from using the log4php as a subfolder to having it be a pear extension but I am getting a class not found unless I purposefully include that path in my script. Should it load automatically?

I am not a pear expert, but my expectation is it should load automatically. Can you show us your folder structure?

Cheers

> Mike
>
> -----Original Message-----
> From: Christian Grobmeier [mailto:[hidden email]]
> Sent: Tuesday, May 15, 2012 1:51 PM
> To: Log4PHP User
> Subject: Re: Convert to array from XML
>
> On Tue, May 15, 2012 at 7:34 PM, Michael Sole <[hidden email]> wrote:
>> We are using log4php quite extensively in our application. We began
>> by using the XML config file but found that too much of a hassle as
>> we end up with lots of them. The array method of configuring loggers
>> seems much more efficient but I am having difficulty converting our
>> xml file to the array. I am sadly not able to find a good enough
>> example to use as a template. Can someone please help me by converting this XML into an array?
>
> Have you seen that for each component is an example for xml and php
> (array) available?
> F.e.
> http://logging.apache.org/log4php/docs/appenders/rolling-file.html
>
> A quick start for php configuration:
> http://logging.apache.org/log4php/docs/configuration.html
>
> HTH
> Christian
>
>>
>>
>>
>> <log4php:configuration
>> xmlns:log4php="http://logging.apache.org/log4php/">
>>
>>     <appender name="myAppender" class="LoggerAppenderDailyFile">
>>
>>                 <layout class="LoggerLayoutTTCC" />
>>
>>     <param name="datePattern" value="Y-m-d" />
>>
>>         <param name="file"
>> value="/var/www/virtual/derver.net/michael/htdocs/log/michaeldev%s.lo
>> g
>> " />
>>
>>     </appender>
>>
>>                 <appender name="myAppender"
>> class="LoggerAppenderEcho">
>>
>>     <layout class="LoggerLayoutTTCC" />
>>
>> </appender>
>>
>>     <root>
>>
>>         <level value="WARN" />
>>
>>         <appender_ref ref="myAppender" />
>>
>>     </root>
>>
>> </log4php:configuration>
>>
>>
>>
>> Also, I have had trouble (in the past) with relative paths in the
>> XML, I assume the array method won’t have these issues?
>>
>> _______________
>>
>> Michael F. Sole
>> [hidden email]
>>
>> Office: 732.632.8801, ext. 261
>> Mobile: 516.592.3683
>>
>> Fax: 732.632.3599
>>
>> Gold Mobile
>> www.gold-mobile.com
>>
>> Mobile Health Tech Group
>> www.mobilehealthtech.md
>>
>> This e-mail and any files transmitted are intended solely for the use
>> of the individual or entity to whom they are addressed, and for the
>> use of Gold Mobile.  Any other use is strictly prohibited.
>>
>>
>
>
>
> --
> http://www.grobmeier.de
> https://www.timeandbill.de



--
http://www.grobmeier.de
https://www.timeandbill.de
Reply | Threaded
Open this post in threaded view
|

Re: Convert to array from XML

Florian Semm
In reply to this post by Michael Sole-2
Am 15.05.2012 19:34, schrieb Michael Sole:

We are using log4php quite extensively in our application. We began by using the XML config file but found that too much of a hassle as we end up with lots of them. The array method of configuring loggers seems much more efficient but I am having difficulty converting our xml file to the array. I am sadly not able to find a good enough example to use as a template. Can someone please help me by converting this XML into an array?

 

<log4php:configuration xmlns:log4php="http://logging.apache.org/log4php/">

    <appender name="myAppender" class="LoggerAppenderDailyFile">      

                <layout class="LoggerLayoutTTCC" />

    <param name="datePattern" value="Y-m-d" />

        <param name="file" value="/var/www/virtual/derver.net/michael/htdocs/log/michaeldev%s.log" />

    </appender>

                <appender name="myAppender" class="LoggerAppenderEcho">

    <layout class="LoggerLayoutTTCC" />

</appender>

    <root>

        <level value="WARN" />

        <appender_ref ref="myAppender" />

    </root>

</log4php:configuration>

 

Also, I have had trouble (in the past) with relative paths in the XML, I assume the array method won’t have these issues?

_______________

Michael F. Sole
[hidden email]

Office: 732.632.8801, ext. 261
Mobile: 516.592.3683

Fax: 732.632.3599

Gold Mobile
www.gold-mobile.com  

Mobile Health Tech Group
www.mobilehealthtech.md

This e-mail and any files transmitted are intended solely for the use of the individual or entity to whom they are addressed, and for the use of Gold Mobile.  Any other use is strictly prohibited.

 

Hey Michael,

here's your XML as array:

array(
    'appenders' => array(
        'myAppender'=>array(
            'class'=> 'LoggerAppenderDailyFile',
            'layout'=> array(
                'class'=>'LoggerLayoutTTCC'
            ),
            'params'=>array(
                'datePattern'=>'Y-m-d',
                'file'=>'/var/www/virtual/derver.net/michael/htdocs/log/michaeldev%s.log'
            )
        ),
        'myAppender'=>array(
            'class'=> 'LoggerAppenderEcho',
            'layout'=> array(
                'class'=>'LoggerLayoutTTCC'
            )
        )   
    ),
    'rootLogger'=> array(
        'level'=>'WARN',
        'appenders'=>array('myAppender')
    )
)

The params-option in the documentation (array as config) is missing.


regards

Florian
Reply | Threaded
Open this post in threaded view
|

RE: Convert to array from XML

Michael Sole-2

Thanks!!!!!

 

Not sure why this isn’t better documented. If multiple arrays didn’t make my eyes bleed I would offer to doc this better. However it seems a more intuitive approach would make more sense. Something like:

 

Array(‘logger’ => array(‘param’=>’value’, ‘param2’=>’value’));

 

Or something like that, we don’t need to completely mimic XML, I think

 

From: Florian Semm [mailto:[hidden email]]
Sent: Wednesday, May 16, 2012 1:23 AM
To: Log4PHP User
Subject: Re: Convert to array from XML

 

Am 15.05.2012 19:34, schrieb Michael Sole:

We are using log4php quite extensively in our application. We began by using the XML config file but found that too much of a hassle as we end up with lots of them. The array method of configuring loggers seems much more efficient but I am having difficulty converting our xml file to the array. I am sadly not able to find a good enough example to use as a template. Can someone please help me by converting this XML into an array?

 

<log4php:configuration xmlns:log4php="http://logging.apache.org/log4php/">

    <appender name="myAppender" class="LoggerAppenderDailyFile">      

                <layout class="LoggerLayoutTTCC" />

    <param name="datePattern" value="Y-m-d" />

        <param name="file" value="/var/www/virtual/derver.net/michael/htdocs/log/michaeldev%s.log" />

    </appender>

                <appender name="myAppender" class="LoggerAppenderEcho">

    <layout class="LoggerLayoutTTCC" />

</appender>

    <root>

        <level value="WARN" />

        <appender_ref ref="myAppender" />

    </root>

</log4php:configuration>

 

Also, I have had trouble (in the past) with relative paths in the XML, I assume the array method won’t have these issues?

_______________

Michael F. Sole
[hidden email]

Office: 732.632.8801, ext. 261
Mobile: 516.592.3683

Fax: 732.632.3599

Gold Mobile
www.gold-mobile.com  

Mobile Health Tech Group
www.mobilehealthtech.md

This e-mail and any files transmitted are intended solely for the use of the individual or entity to whom they are addressed, and for the use of Gold Mobile.  Any other use is strictly prohibited.

 

Hey Michael,

here's your XML as array:

array(
    'appenders' => array(
        'myAppender'=>array(
            'class'=> 'LoggerAppenderDailyFile',
            'layout'=> array(
                'class'=>'LoggerLayoutTTCC'
            ),
            'params'=>array(
                'datePattern'=>'Y-m-d',
                'file'=>'/var/www/virtual/derver.net/michael/htdocs/log/michaeldev%s.log'
            )
        ),
        'myAppender'=>array(
            'class'=> 'LoggerAppenderEcho',
            'layout'=> array(
                'class'=>'LoggerLayoutTTCC'
            )
        )   
    ),
    'rootLogger'=> array(
        'level'=>'WARN',
        'appenders'=>array('myAppender')
    )
)

The params-option in the documentation (array as config) is missing.


regards

Florian

Reply | Threaded
Open this post in threaded view
|

Re: Convert to array from XML

Christian grobmeier
Hello Michael,

On Wed, May 16, 2012 at 7:46 PM, Michael Sole <[hidden email]> wrote:
> Thanks!!!!!
>
> Not sure why this isn’t better documented. If multiple arrays didn’t make my
> eyes bleed I would offer to doc this better. However it seems a more
> intuitive approach would make more sense. Something like:
>
> Array(‘logger’ => array(‘param’=>’value’, ‘param2’=>’value’));
>
> Or something like that, we don’t need to completely mimic XML, I think

That's right.

You are more than welcome to help us making log4php better. We are a
small team and appreciate any ideas, help, code patches, docs etc we
can get.

As for backwards compatibility I guess we need to stick with what we
have now, but nothing prevents us to create another configurator which
might be enabled *somehow* at request.

Cheers
Christian

>
>
>
> From: Florian Semm [mailto:[hidden email]]
> Sent: Wednesday, May 16, 2012 1:23 AM
>
>
> To: Log4PHP User
> Subject: Re: Convert to array from XML
>
>
>
> Am 15.05.2012 19:34, schrieb Michael Sole:
>
> We are using log4php quite extensively in our application. We began by using
> the XML config file but found that too much of a hassle as we end up with
> lots of them. The array method of configuring loggers seems much more
> efficient but I am having difficulty converting our xml file to the array. I
> am sadly not able to find a good enough example to use as a template. Can
> someone please help me by converting this XML into an array?
>
>
>
> <log4php:configuration xmlns:log4php="http://logging.apache.org/log4php/">
>
>     <appender name="myAppender" class="LoggerAppenderDailyFile">
>
>                 <layout class="LoggerLayoutTTCC" />
>
>     <param name="datePattern" value="Y-m-d" />
>
>         <param name="file"
> value="/var/www/virtual/derver.net/michael/htdocs/log/michaeldev%s.log" />
>
>     </appender>
>
>                 <appender name="myAppender" class="LoggerAppenderEcho">
>
>     <layout class="LoggerLayoutTTCC" />
>
> </appender>
>
>     <root>
>
>         <level value="WARN" />
>
>         <appender_ref ref="myAppender" />
>
>     </root>
>
> </log4php:configuration>
>
>
>
> Also, I have had trouble (in the past) with relative paths in the XML, I
> assume the array method won’t have these issues?
>
> _______________
>
> Michael F. Sole
> [hidden email]
>
> Office: 732.632.8801, ext. 261
> Mobile: 516.592.3683
>
> Fax: 732.632.3599
>
> Gold Mobile
> www.gold-mobile.com
>
> Mobile Health Tech Group
> www.mobilehealthtech.md
>
> This e-mail and any files transmitted are intended solely for the use of the
> individual or entity to whom they are addressed, and for the use of Gold
> Mobile.  Any other use is strictly prohibited.
>
>
>
> Hey Michael,
>
> here's your XML as array:
>
> array(
>     'appenders' => array(
>         'myAppender'=>array(
>             'class'=> 'LoggerAppenderDailyFile',
>             'layout'=> array(
>                 'class'=>'LoggerLayoutTTCC'
>             ),
>             'params'=>array(
>                 'datePattern'=>'Y-m-d',
>
> 'file'=>'/var/www/virtual/derver.net/michael/htdocs/log/michaeldev%s.log'
>             )
>         ),
>         'myAppender'=>array(
>             'class'=> 'LoggerAppenderEcho',
>             'layout'=> array(
>                 'class'=>'LoggerLayoutTTCC'
>             )
>         )
>     ),
>     'rootLogger'=> array(
>         'level'=>'WARN',
>         'appenders'=>array('myAppender')
>     )
> )
>
> The params-option in the documentation (array as config) is missing.
>
>
> regards
>
> Florian



--
http://www.grobmeier.de
https://www.timeandbill.de
Reply | Threaded
Open this post in threaded view
|

RE: Convert to array from XML

Michael Sole-2
I would love to be able to write new semantics for configs or at least propose them and I will get working on them right away. As for backwards compatibility you could add a new/old flag that would determine the config params type that would default to old if not specified.

Logger::configure($logConfig); would use the old
Logger::configure($logConfig,false); would use the old
Logger::configure($logConfig,true); would use the new

The essence of how I would suggest improving this would be able to define a logger with a straight list of params, no need to have hierarchical params for something as simple as logging.

I was not the only one who had trouble understand how to configure this many other people that work for me did as well. We got it working but through lots of sweats.



-----Original Message-----
From: Christian Grobmeier [mailto:[hidden email]]
Sent: Wednesday, May 16, 2012 1:57 PM
To: Log4PHP User
Subject: Re: Convert to array from XML

Hello Michael,

On Wed, May 16, 2012 at 7:46 PM, Michael Sole <[hidden email]> wrote:
> Thanks!!!!!
>
> Not sure why this isn’t better documented. If multiple arrays didn’t
> make my eyes bleed I would offer to doc this better. However it seems
> a more intuitive approach would make more sense. Something like:
>
> Array(‘logger’ => array(‘param’=>’value’, ‘param2’=>’value’));
>
> Or something like that, we don’t need to completely mimic XML, I think

That's right.

You are more than welcome to help us making log4php better. We are a small team and appreciate any ideas, help, code patches, docs etc we can get.

As for backwards compatibility I guess we need to stick with what we have now, but nothing prevents us to create another configurator which might be enabled *somehow* at request.

Cheers
Christian

>
>
>
> From: Florian Semm [mailto:[hidden email]]
> Sent: Wednesday, May 16, 2012 1:23 AM
>
>
> To: Log4PHP User
> Subject: Re: Convert to array from XML
>
>
>
> Am 15.05.2012 19:34, schrieb Michael Sole:
>
> We are using log4php quite extensively in our application. We began by
> using the XML config file but found that too much of a hassle as we
> end up with lots of them. The array method of configuring loggers
> seems much more efficient but I am having difficulty converting our
> xml file to the array. I am sadly not able to find a good enough
> example to use as a template. Can someone please help me by converting this XML into an array?
>
>
>
> <log4php:configuration
> xmlns:log4php="http://logging.apache.org/log4php/">
>
>     <appender name="myAppender" class="LoggerAppenderDailyFile">
>
>                 <layout class="LoggerLayoutTTCC" />
>
>     <param name="datePattern" value="Y-m-d" />
>
>         <param name="file"
> value="/var/www/virtual/derver.net/michael/htdocs/log/michaeldev%s.log
> " />
>
>     </appender>
>
>                 <appender name="myAppender"
> class="LoggerAppenderEcho">
>
>     <layout class="LoggerLayoutTTCC" />
>
> </appender>
>
>     <root>
>
>         <level value="WARN" />
>
>         <appender_ref ref="myAppender" />
>
>     </root>
>
> </log4php:configuration>
>
>
>
> Also, I have had trouble (in the past) with relative paths in the XML,
> I assume the array method won’t have these issues?
>
> _______________
>
> Michael F. Sole
> [hidden email]
>
> Office: 732.632.8801, ext. 261
> Mobile: 516.592.3683
>
> Fax: 732.632.3599
>
> Gold Mobile
> www.gold-mobile.com
>
> Mobile Health Tech Group
> www.mobilehealthtech.md
>
> This e-mail and any files transmitted are intended solely for the use
> of the individual or entity to whom they are addressed, and for the
> use of Gold Mobile.  Any other use is strictly prohibited.
>
>
>
> Hey Michael,
>
> here's your XML as array:
>
> array(
>     'appenders' => array(
>         'myAppender'=>array(
>             'class'=> 'LoggerAppenderDailyFile',
>             'layout'=> array(
>                 'class'=>'LoggerLayoutTTCC'
>             ),
>             'params'=>array(
>                 'datePattern'=>'Y-m-d',
>
> 'file'=>'/var/www/virtual/derver.net/michael/htdocs/log/michaeldev%s.log'
>             )
>         ),
>         'myAppender'=>array(
>             'class'=> 'LoggerAppenderEcho',
>             'layout'=> array(
>                 'class'=>'LoggerLayoutTTCC'
>             )
>         )
>     ),
>     'rootLogger'=> array(
>         'level'=>'WARN',
>         'appenders'=>array('myAppender')
>     )
> )
>
> The params-option in the documentation (array as config) is missing.
>
>
> regards
>
> Florian



--
http://www.grobmeier.de
https://www.timeandbill.de
Reply | Threaded
Open this post in threaded view
|

Re: Convert to array from XML

Christian grobmeier
On Wed, May 16, 2012 at 8:15 PM, Michael Sole <[hidden email]> wrote:
> I would love to be able to write new semantics for configs or at least propose them and I will get working on them right away.

You are welcome!

>As for backwards compatibility you could add a new/old flag that would determine the config params type that would default to old if not specified.
>
> Logger::configure($logConfig); would use the old
> Logger::configure($logConfig,false); would use the old
> Logger::configure($logConfig,true); would use the new

I would even prefer some other key, like:
Logger::configure($logConfig,"array-2.0");

Or maybe something inside the configuration itself which helps
identifying its version.

> The essence of how I would suggest improving this would be able to define a logger with a straight list of params, no need to have hierarchical params for something as simple as logging.

LIke properties? We were not happy with them... so you probably need
to show an example how you would do it.

> I was not the only one who had trouble understand how to configure this many other people that work for me did as well. We got it working but through lots of sweats.

I believe it. Its not trivial to get log4php/j to work. I strongly
feel that we should make it "as simple as possible". Actually Ivan has
made a lots of effort on this and he improved everything already tons.
Lets hear how he thinks we can use different configuration options.
Probably we can manage to make some kind of plugin mechanism.

Cheers + thanks for your valuable feedback!
Christian

>
>
>
> -----Original Message-----
> From: Christian Grobmeier [mailto:[hidden email]]
> Sent: Wednesday, May 16, 2012 1:57 PM
> To: Log4PHP User
> Subject: Re: Convert to array from XML
>
> Hello Michael,
>
> On Wed, May 16, 2012 at 7:46 PM, Michael Sole <[hidden email]> wrote:
>> Thanks!!!!!
>>
>> Not sure why this isn’t better documented. If multiple arrays didn’t
>> make my eyes bleed I would offer to doc this better. However it seems
>> a more intuitive approach would make more sense. Something like:
>>
>> Array(‘logger’ => array(‘param’=>’value’, ‘param2’=>’value’));
>>
>> Or something like that, we don’t need to completely mimic XML, I think
>
> That's right.
>
> You are more than welcome to help us making log4php better. We are a small team and appreciate any ideas, help, code patches, docs etc we can get.
>
> As for backwards compatibility I guess we need to stick with what we have now, but nothing prevents us to create another configurator which might be enabled *somehow* at request.
>
> Cheers
> Christian
>
>>
>>
>>
>> From: Florian Semm [mailto:[hidden email]]
>> Sent: Wednesday, May 16, 2012 1:23 AM
>>
>>
>> To: Log4PHP User
>> Subject: Re: Convert to array from XML
>>
>>
>>
>> Am 15.05.2012 19:34, schrieb Michael Sole:
>>
>> We are using log4php quite extensively in our application. We began by
>> using the XML config file but found that too much of a hassle as we
>> end up with lots of them. The array method of configuring loggers
>> seems much more efficient but I am having difficulty converting our
>> xml file to the array. I am sadly not able to find a good enough
>> example to use as a template. Can someone please help me by converting this XML into an array?
>>
>>
>>
>> <log4php:configuration
>> xmlns:log4php="http://logging.apache.org/log4php/">
>>
>>     <appender name="myAppender" class="LoggerAppenderDailyFile">
>>
>>                 <layout class="LoggerLayoutTTCC" />
>>
>>     <param name="datePattern" value="Y-m-d" />
>>
>>         <param name="file"
>> value="/var/www/virtual/derver.net/michael/htdocs/log/michaeldev%s.log
>> " />
>>
>>     </appender>
>>
>>                 <appender name="myAppender"
>> class="LoggerAppenderEcho">
>>
>>     <layout class="LoggerLayoutTTCC" />
>>
>> </appender>
>>
>>     <root>
>>
>>         <level value="WARN" />
>>
>>         <appender_ref ref="myAppender" />
>>
>>     </root>
>>
>> </log4php:configuration>
>>
>>
>>
>> Also, I have had trouble (in the past) with relative paths in the XML,
>> I assume the array method won’t have these issues?
>>
>> _______________
>>
>> Michael F. Sole
>> [hidden email]
>>
>> Office: 732.632.8801, ext. 261
>> Mobile: 516.592.3683
>>
>> Fax: 732.632.3599
>>
>> Gold Mobile
>> www.gold-mobile.com
>>
>> Mobile Health Tech Group
>> www.mobilehealthtech.md
>>
>> This e-mail and any files transmitted are intended solely for the use
>> of the individual or entity to whom they are addressed, and for the
>> use of Gold Mobile.  Any other use is strictly prohibited.
>>
>>
>>
>> Hey Michael,
>>
>> here's your XML as array:
>>
>> array(
>>     'appenders' => array(
>>         'myAppender'=>array(
>>             'class'=> 'LoggerAppenderDailyFile',
>>             'layout'=> array(
>>                 'class'=>'LoggerLayoutTTCC'
>>             ),
>>             'params'=>array(
>>                 'datePattern'=>'Y-m-d',
>>
>> 'file'=>'/var/www/virtual/derver.net/michael/htdocs/log/michaeldev%s.log'
>>             )
>>         ),
>>         'myAppender'=>array(
>>             'class'=> 'LoggerAppenderEcho',
>>             'layout'=> array(
>>                 'class'=>'LoggerLayoutTTCC'
>>             )
>>         )
>>     ),
>>     'rootLogger'=> array(
>>         'level'=>'WARN',
>>         'appenders'=>array('myAppender')
>>     )
>> )
>>
>> The params-option in the documentation (array as config) is missing.
>>
>>
>> regards
>>
>> Florian
>
>
>
> --
> http://www.grobmeier.de
> https://www.timeandbill.de



--
http://www.grobmeier.de
https://www.timeandbill.de
Reply | Threaded
Open this post in threaded view
|

RE: Convert to array from XML

Michael Sole-2
No I wouldn't use properties, Arrays for params is good and we use them all the time but having multi-mutli-dimensional arrays is where it becomes counter-intuitive. It also appears you have sub arrays that refer to other arrays by name. Seems needless to me.

-----Original Message-----
From: Christian Grobmeier [mailto:[hidden email]]
Sent: Wednesday, May 16, 2012 2:21 PM
To: Log4PHP User
Subject: Re: Convert to array from XML

On Wed, May 16, 2012 at 8:15 PM, Michael Sole <[hidden email]> wrote:
> I would love to be able to write new semantics for configs or at least propose them and I will get working on them right away.

You are welcome!

>As for backwards compatibility you could add a new/old flag that would determine the config params type that would default to old if not specified.
>
> Logger::configure($logConfig); would use the old
> Logger::configure($logConfig,false); would use the old
> Logger::configure($logConfig,true); would use the new

I would even prefer some other key, like:
Logger::configure($logConfig,"array-2.0");

Or maybe something inside the configuration itself which helps identifying its version.

> The essence of how I would suggest improving this would be able to define a logger with a straight list of params, no need to have hierarchical params for something as simple as logging.

LIke properties? We were not happy with them... so you probably need to show an example how you would do it.

> I was not the only one who had trouble understand how to configure this many other people that work for me did as well. We got it working but through lots of sweats.

I believe it. Its not trivial to get log4php/j to work. I strongly feel that we should make it "as simple as possible". Actually Ivan has made a lots of effort on this and he improved everything already tons.
Lets hear how he thinks we can use different configuration options.
Probably we can manage to make some kind of plugin mechanism.

Cheers + thanks for your valuable feedback!
Christian

>
>
>
> -----Original Message-----
> From: Christian Grobmeier [mailto:[hidden email]]
> Sent: Wednesday, May 16, 2012 1:57 PM
> To: Log4PHP User
> Subject: Re: Convert to array from XML
>
> Hello Michael,
>
> On Wed, May 16, 2012 at 7:46 PM, Michael Sole <[hidden email]> wrote:
>> Thanks!!!!!
>>
>> Not sure why this isn’t better documented. If multiple arrays didn’t
>> make my eyes bleed I would offer to doc this better. However it seems
>> a more intuitive approach would make more sense. Something like:
>>
>> Array(‘logger’ => array(‘param’=>’value’, ‘param2’=>’value’));
>>
>> Or something like that, we don’t need to completely mimic XML, I
>> think
>
> That's right.
>
> You are more than welcome to help us making log4php better. We are a small team and appreciate any ideas, help, code patches, docs etc we can get.
>
> As for backwards compatibility I guess we need to stick with what we have now, but nothing prevents us to create another configurator which might be enabled *somehow* at request.
>
> Cheers
> Christian
>
>>
>>
>>
>> From: Florian Semm [mailto:[hidden email]]
>> Sent: Wednesday, May 16, 2012 1:23 AM
>>
>>
>> To: Log4PHP User
>> Subject: Re: Convert to array from XML
>>
>>
>>
>> Am 15.05.2012 19:34, schrieb Michael Sole:
>>
>> We are using log4php quite extensively in our application. We began
>> by using the XML config file but found that too much of a hassle as
>> we end up with lots of them. The array method of configuring loggers
>> seems much more efficient but I am having difficulty converting our
>> xml file to the array. I am sadly not able to find a good enough
>> example to use as a template. Can someone please help me by converting this XML into an array?
>>
>>
>>
>> <log4php:configuration
>> xmlns:log4php="http://logging.apache.org/log4php/">
>>
>>     <appender name="myAppender" class="LoggerAppenderDailyFile">
>>
>>                 <layout class="LoggerLayoutTTCC" />
>>
>>     <param name="datePattern" value="Y-m-d" />
>>
>>         <param name="file"
>> value="/var/www/virtual/derver.net/michael/htdocs/log/michaeldev%s.lo
>> g
>> " />
>>
>>     </appender>
>>
>>                 <appender name="myAppender"
>> class="LoggerAppenderEcho">
>>
>>     <layout class="LoggerLayoutTTCC" />
>>
>> </appender>
>>
>>     <root>
>>
>>         <level value="WARN" />
>>
>>         <appender_ref ref="myAppender" />
>>
>>     </root>
>>
>> </log4php:configuration>
>>
>>
>>
>> Also, I have had trouble (in the past) with relative paths in the
>> XML, I assume the array method won’t have these issues?
>>
>> _______________
>>
>> Michael F. Sole
>> [hidden email]
>>
>> Office: 732.632.8801, ext. 261
>> Mobile: 516.592.3683
>>
>> Fax: 732.632.3599
>>
>> Gold Mobile
>> www.gold-mobile.com
>>
>> Mobile Health Tech Group
>> www.mobilehealthtech.md
>>
>> This e-mail and any files transmitted are intended solely for the use
>> of the individual or entity to whom they are addressed, and for the
>> use of Gold Mobile.  Any other use is strictly prohibited.
>>
>>
>>
>> Hey Michael,
>>
>> here's your XML as array:
>>
>> array(
>>     'appenders' => array(
>>         'myAppender'=>array(
>>             'class'=> 'LoggerAppenderDailyFile',
>>             'layout'=> array(
>>                 'class'=>'LoggerLayoutTTCC'
>>             ),
>>             'params'=>array(
>>                 'datePattern'=>'Y-m-d',
>>
>> 'file'=>'/var/www/virtual/derver.net/michael/htdocs/log/michaeldev%s.log'
>>             )
>>         ),
>>         'myAppender'=>array(
>>             'class'=> 'LoggerAppenderEcho',
>>             'layout'=> array(
>>                 'class'=>'LoggerLayoutTTCC'
>>             )
>>         )
>>     ),
>>     'rootLogger'=> array(
>>         'level'=>'WARN',
>>         'appenders'=>array('myAppender')
>>     )
>> )
>>
>> The params-option in the documentation (array as config) is missing.
>>
>>
>> regards
>>
>> Florian
>
>
>
> --
> http://www.grobmeier.de
> https://www.timeandbill.de



--
http://www.grobmeier.de
https://www.timeandbill.de
Reply | Threaded
Open this post in threaded view
|

Re: Convert to array from XML

Florian Semm
In reply to this post by Michael Sole-2
Am 16.05.2012 19:46, schrieb Michael Sole:

Thanks!!!!!

 

Not sure why this isn’t better documented. If multiple arrays didn’t make my eyes bleed I would offer to doc this better.

I think there is still an issue in JIRA "improve documentation", or somethink like that.

However it seems a more intuitive approach would make more sense. Something like:

 

Array(‘logger’ => array(‘param’=>’value’, ‘param2’=>’value’));


Complex logger-structures cause complex config-structures. Some options of log4php maybe not important than others, but you need a way to configure all this options.

Maybe it's possible to reduce the options of some components, which are not needed.

 

Or something like that, we don’t need to completely mimic XML, I think


regards

Florian
Reply | Threaded
Open this post in threaded view
|

Re: Convert to array from XML

Ivan Habunek
Somehow I totally missed this discussion. I was away at the time, and
missed it when I got back...

First, Michael, there is a passage in the docs:
http://logging.apache.org/log4php/docs/configuration.html

which says:
--
Hint: to translate a XML or properties configuration file to PHP, run
the following code:
$configurator = new LoggerConfiguratorDefault();
$config = $configurator->parse('/path/to/config.xml');
--

This will convert your .xml (or .properties) file to a config array.

Second, I designed the array structure to be easy to parse and apply.
Also, it made sense to me. It still lacks some docs, but there are a
lot of examples floating around (at least one for each appender,
layout and filter), and with the xml->php converter I thought we're
more or less covered. There's always room for improvement, though. I
plan to put some more effort into this for the next release.

We're open for new ideas, but I really don't want to have 10
configuration formats if it's possible. :)

Regards,
Ivan

On 17 May 2012 13:49, Florian Semm <[hidden email]> wrote:

> Am 16.05.2012 19:46, schrieb Michael Sole:
>
> Thanks!!!!!
>
>
>
> Not sure why this isn’t better documented. If multiple arrays didn’t make my
> eyes bleed I would offer to doc this better.
>
> I think there is still an issue in JIRA "improve documentation", or
> somethink like that.
>
> However it seems a more intuitive approach would make more sense. Something
> like:
>
>
>
> Array(‘logger’ => array(‘param’=>’value’, ‘param2’=>’value’));
>
>
> Complex logger-structures cause complex config-structures. Some options of
> log4php maybe not important than others, but you need a way to configure all
> this options.
>
> Maybe it's possible to reduce the options of some components, which are not
> needed.
>
>
>
>
> Or something like that, we don’t need to completely mimic XML, I think
>
>
> regards
>
> Florian