Usage guidance

6 views
Skip to first unread message

Vikas

unread,
Jul 21, 2009, 11:30:53 AM7/21/09
to slf4fx-users
Hi,

I am building a simple Client-Server Application (Client using flex,
mxml and server running on BlazeDS/Tomcat). The basic requirement is
to get all the client loggings available on the blazeds server side.

After a lot of searching, I feel that slf4fx would be the best way to
go to meet the requirement.

Since I am new to the Java world, I am not able to understand how to
use slf4fx in my environment. So please bear with me if my questions
are too elementary.

Q1) In SampleApp.mxml, what is the relevance of

----- Log.getLogger("org.room13.slf4fx.MyApplication");
----- Log.addTarget(new Slf4FxLoggingTarget("myApplication",
"mySecret"));

what is "MyApplication" in getLogger()?
what are "myApplication" and "mySecret" in addTarget()?

Q2) On the server side, will the slf4fx logging be separate from the
tomcat logging?

Q3) Will the logging always run in a console window?

Rest of the questions probably after your response

Thanks
Vikku77

d12v

unread,
Jul 21, 2009, 12:44:53 PM7/21/09
to slf4fx-users
Hello,

First of all - thank you for the questions :)

> Q1) In SampleApp.mxml, what is the relevance of
>
> ----- Log.getLogger("org.room13.slf4fx.MyApplication");
> ----- Log.addTarget(new Slf4FxLoggingTarget("myApplication",
> "mySecret"));
>
> what is "MyApplication" in getLogger()?
> what are "myApplication" and "mySecret" in addTarget()?
>

Log.getLogger(...) returns named logger logger. It is usual
development practice that each class has own logger. So
"org.room13.slf4fx.MyApplication" here is just class name and it will
be passed to server side as part of slf4j log record category.

Following is cite from Usage page http://code.google.com/p/slf4fx/wiki/Usage

===
All log events from applications will have category in form:

slf4fx.APPLICATION_ID.LOG_RECORD_CATEGORY
Where slf4fx is constant prefix. APPLICATION_ID is application name
given as parameter to Slf4FxLoggingTarget on client side. Application
id is optional parameter. LOG_RECORD_CATEGORY is logger category on
client side.
===

new Slf4FxLoggingTarget("myApplication", "mySecret")
creates SLF4Fx logging target that sends all incoming records to
slf4fx server. The constructor accepts 4 parameters:

public function Slf4FxLoggingTarget(applicationName:String,
secret:String = "",
logServer:String =
"localhost", logServerPort:uint = 18888)

As you can see the only required parameter is application name. That
parameter also will be used as part of slf4fj log record category.
It's required since you may have more than one flex application hosted
on the server and this will help you to separate log records from all
those applications. You can use any meaningful value for this
parameter but avoid using spaces as it may lead to some problems on
logging framework used on server side. In example it was
"myApplication" because it is my application :)
"secret" is the way to get logging from particular application
instance. By default slf4fx server accepts all incoming requests. But
if you somehow define secret for the application instance on client
side and provides the same secret on server side then server will
accept records only from that application instance. But this is not
your case and you can omit second parameter. logServer and
logServerPort describe themselves.

> Q2) On the server side, will the slf4fx logging be separate from the
> tomcat logging?
Yes it will. But configuration depends on the way you use for
integration slf4fx server with your web application. You can use
standalone slf4fx server. In this case you already have log file
separated from tomcat logs. If you integrates slf4fx into your web
application then you have to properly configure selected logging
framework. Anyway logging configuration described in "Configure
logging" of http://code.google.com/p/slf4fx/wiki/Usage

>
> Q3) Will the logging always run in a console window?
No. See answer on previous question.

>
> Rest of the questions probably after your response
>
> Thanks
> Vikku77

Thank you :)
P.S. I know java better then English :( so I just hope my answers are
clear enough

Vikas Sharma

unread,
Jul 23, 2009, 12:07:14 AM7/23/09
to slf4fx...@googlegroups.com
Thanks so much for the quick response.
 
I have got my client and server working ... I can see a lot of value of using slf4fx.
 
Now to the next set of questions :)
 
1) I want to start this logging server when my tomcat starts up. How do I do that? Any additional configuration?
 
2) Also, I want to it to run the server as a background process and not visible to the end user.
 
3) I see that the client logging is happening in slf4fx-client.log. Where does the server logging go? Does it also get onto a file similar to slf4fx-client.log?
 
4) Does the slf4fx-client.log overwrite itself on every restart or dows it roll over once it reaches a particular file size?
 
5) Can the server create a unique log name for each client instance (for example: slf4fx-client_id1.log, slf4fx-client_id2.log etc)? If so, where do I configure it?
 
Thanks for the continued support.
 
Thanks,
Vikku77

d12v

unread,
Jul 23, 2009, 2:30:47 AM7/23/09
to slf4fx-users


On Jul 23, 8:07 am, Vikas Sharma <vikk...@gmail.com> wrote:
> Thanks so much for the quick response.
>
> I have got my client and server working ... I can see a lot of value of
> using slf4fx.
>
> Now to the next set of questions :)
>
> 1) I want to start this logging server when my tomcat starts up. How do I do
> that? Any additional configuration?
>

You can choose any appropriate way for your application. SLF4FxServer
bean does not require any specific configuration for that. See
http://code.google.com/p/slf4fx/wiki/Integration how to integrate
server with your application.

> 2) Also, I want to it to run the server as a background process and not
> visible to the end user.
>
I guess any server process is not "visible" to end-user.

> 3) I see that the client logging is happening in slf4fx-client.log. Where
> does the server logging go? Does it also get onto a file similar to
> slf4fx-client.log?
>
Google for "logging in tomcat". That is not SLF4Fx.

> 4) Does the slf4fx-client.log overwrite itself on every restart or dows it
> roll over once it reaches a particular file size?
>
Yes, default configuration overwrite default log file on every
restart. Just configure logging framework you use in your application
and which is supported by slf4j project. SLF4Fx is just bridge between
Flex Logging Framework and slf4j

> 5) Can the server create a unique log name for each client instance (for
> example: slf4fx-client_id1.log, slf4fx-client_id2.log etc)? If so, where do
> I configure it?
See answer for Q4
> > logging" ofhttp://code.google.com/p/slf4fx/wiki/Usage
Reply all
Reply to author
Forward
0 new messages