平台日志组件使用介绍

平台日志组件使用介绍
需要导入的类:
import com.frameworkset.platform.sysmgrcore.entity.Organization;
import com.frameworkset.platform.sysmgrcore.manager.LogManager;
import com.frameworkset.platform.sysmgrcore.manager.SecurityDatabase;

如果是登录用户,记录日志的方法为:

try {

LogManager logMgr = SecurityDatabase.getLogManager();
//以下是以一个quartz任务执行日志记录为实例说明日志组件的使用方法
AccessControl control = AccessControl.getAccessControl();
String userAccount = "";//操作账号
String operContent = "";//操作内容
String machineID = "";//操作主机标识
String orgID = "";//操作员所属部门id
userAccount = control.getUserAccount();
String userName = control.getUserName();//操作员中文名称
String subsystem = control.getCurrentSystemName();//操作系统名称
machineID = control.getMachinedID();//客户端ip信息
Organization org = control.getChargeOrg();//获取当前用户所属机构对象
if(org != null)
{
orgID = org.getOrgId();
}
operContent = userAccount + "(" + userName + ") 从[" + subsystem + "]同步用户数据开始";
String operModle = "主数据同步";//日志所属模块
logMgr.log(userAccount,orgID,operModle, machineID,
operContent ,"", Log.INSERT_OPER_TYPE);

} catch (Exception e) {
e.printStackTrace();
}
//日志记录结束



如果记录日志时,用户可能登录系统,也可能没有登录系统,记录日志时需判断用户身份(是否登录)。以下是以一个quartz任务执行日志记录为实例说明日志组件的这种使用方法:

try {

LogManager logMgr = SecurityDatabase.getLogManager();
//以下是以一个quartz任务执行日志记录为实例说明日志组件的使用方法
AccessControl control = AccessControl.getAccessControl();
String userAccount = "";//操作账号
String operContent = "";//操作内容
String machineID = "";//操作主机标识
String orgID = "";//操作员所属部门id
if(control == AccessControl.getGuest())//匿名用户-guest,登录用户直接忽略这个条件进入下一个环节
{

machineID = SimpleStringUtil.getHostIP();
userAccount = "Quartz定时任务";
operContent = userAccount + "同步用户数据开始";
}
else //登录用户
{
userAccount = control.getUserAccount();
String userName = control.getUserName();//操作员中文名称
String subsystem = control.getCurrentSystemName();//操作系统名称
machineID = control.getMachinedID();//客户端ip信息
Organization org = control.getChargeOrg();//获取当前用户所属机构
if(org != null)
{
orgID = org.getOrgId();
}
operContent = userAccount + "(" + userName + ") 从[" + subsystem + "]同步用户数据开始";
}
String operModle = "主数据同步";//日志所属模块
logMgr.log(userAccount,orgID,operModle, machineID,
operContent ,"", Log.INSERT_OPER_TYPE);

} catch (Exception e) {
e.printStackTrace();
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值