Sathish David Kumar N
asked on
is it possible to create log file for each country
Hi i have deployed my applciation for 22 country with one server . i am using log4j for logging
i need to create for each country is that possible ? like i am connection to DB schema !
i need to create for each country is that possible ? like i am connection to DB schema !
How do you deploy it?
ASKER
its single application only . connect with different schema for that country
There are many ways to do this. I guess what you're talking about is a separate Logger for each country. It depends on how you're instantiating the class so the issue here is in the details and it's hard to give a general answer without knowing more details about your application.
For example, if you instantiate a separate instance of a class for each country, you could make the Logger a field in the instance (as opposed to the usual practice of a static field in the class itself). Then, you could make the name of your Logger in your programs have the name of the country included in the Logger name, eg
Logger myLogger = Logger.getLogger(countryNa me + thisClass.class.getName()) ;
So each instance of thisClass would have the appropriate logger. Then you could issue your log requests in the usual way and have them go to separate appenders based on the logger name.
If this solution is not appropriate, perhaps you could provide more details about how you're connecting to a different schema for each country.
For example, if you instantiate a separate instance of a class for each country, you could make the Logger a field in the instance (as opposed to the usual practice of a static field in the class itself). Then, you could make the name of your Logger in your programs have the name of the country included in the Logger name, eg
Logger myLogger = Logger.getLogger(countryNa
So each instance of thisClass would have the appropriate logger. Then you could issue your log requests in the usual way and have them go to separate appenders based on the logger name.
If this solution is not appropriate, perhaps you could provide more details about how you're connecting to a different schema for each country.
ASKER
Actully how my application is work is !
when user login time i connect to admin schema and check the user deatils after that get country and his schema so after that user transcation are coming with that country schema only !
eg:
I am sathish belonging to india so it will connected to india schema . like wise i want to create log file for each country ?
how can i do that ?
when user login time i connect to admin schema and check the user deatils after that get country and his schema so after that user transcation are coming with that country schema only !
eg:
I am sathish belonging to india so it will connected to india schema . like wise i want to create log file for each country ?
how can i do that ?
And how do you keep track of which schema to connect to when you need it later in the session? Where is that information stored? Do you instantiate a separate instance of each class for each user with the schema stored in that instance?
ASKER
>>>>>>And how do you keep track of which schema to connect to when you need it later in the session? Where is that information stored?
i put it session and used it.
>>>>Do you instantiate a separate instance of each class for each user with the schema stored in that instance?
i am not getting ur point
i put it session and used it.
>>>>Do you instantiate a separate instance of each class for each user with the schema stored in that instance?
i am not getting ur point
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
>>>>>>Logger myLogger = Logger.getLogger(countryNa meObtained FromSessio n + thisClass.class.getName()) ;
is i want to declare anything in log4j.propety file
is i want to declare anything in log4j.propety file
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.