You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
« Previous
Version 7
Next »
Logger writes information in log file.
What does this section cover?
Define logger
A logger is defined in the following path: project_name/src/main/resources/metadata/logbackloggers.xml:
loggername must be unique
<logbackconfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/applications.xsd">
<logbackloggers>
<logbacklogger>
<loggername>kounta</loggername>
<logbackappenderfilename>kounta</logbackappenderfilename>
<logbackclasses>
<logbackclass>
<logbackclassname>com.crm.kounta.webapi.KOUNTAUtilBean</logbackclassname>
</logbackclass>
</logbackclasses>
</logbacklogger>
</logbackloggers>
</logbackconfig>
Retrieve logger
To retrieve the current CRM Session object you have to use getCRMSession() method which is implemented in com.crm.businessobject.CRMBase super class. Note that all CRMBO, CRMUI, CRMProcess and CRMAPIBean classes extend CRMBase.
public CRMDO copy(CRMDO dto)
{
CRMSession session = getCRMSession();
...
}
Use logger
After retrieving the CRM Session, you can use it to get information about the logged in user, the server, the database and the general and formatting settings.
public CRMDO copy(CRMDO dto)
{
CRMSession session = getCRMSession();
if( dto instanceof CUSTOMCRMDORentalTypeProduct)
{
CUSTOMCRMDORentalTypeProduct oldProduct = (CUSTOMCRMDORentalTypeProduct) dto;
CUSTOMCRMDORentalTypeProduct newProduct = (CUSTOMCRMDORentalTypeProduct)oldProduct.clone();
newProduct.setCreatedDate(getCurrentDate());
newProduct.setCreatedByUnit(session.getUnit());
newProduct.setCreatedByUser(ejbSession.getLoggedUser());
newProduct.setUpdatedByUnit(null);
newProduct.setUpdatedByUser(null);
newProduct.setUpdatedDate(null);
}
}