Project

General

Profile

« Previous | Next » 

Revision 5392

Added by berkley over 14 years ago

added a DataOneLogger for event notifications on the CN. The logger is called DataOneLogger and can be managed in the log4j.properties file

View differences:

lib/log4j.properties
33 33
################################################################################
34 34

  
35 35
# set the log level to WARN and the log should be printed to stdout. 
36
log4j.rootLogger=WARN, stdout
36
log4j.rootLogger=FATAL, stdout
37 37
#log4j.threshold=FATAL, ERROR, WARN, INFO
38 38

  
39 39

  
......
68 68
log4j.appender.replication.layout=org.apache.log4j.PatternLayout
69 69
log4j.appender.replication.layout.ConversionPattern=@build.context@ %d{yyyyMMdd-HH:mm:ss}: [%p]: %m [%c]%n
70 70

  
71
############## DataOne Logger ###########################
72
log4j.category.DataOneLogger=d1
73
log4j.appender.d1=org.apache.log4j.FileAppender
74
log4j.appender.d1.File = DataOneEventLog.txt
75
log4j.appender.d1.DatePattern='.'yyyy-ww
76
log4j.appender.d1.maxFileSize=100000KB
77
log4j.appender.d1.maxBackupIndex=10
78
log4j.appender.d1.threshold=info
79
log4j.appender.d1.layout=org.apache.log4j.PatternLayout
80
log4j.appender.d1.layout.ConversionPattern=@build.context@ %d{yyyyMMdd-HH:mm:ss}: [%p]: %m [%c]%n
src/edu/ucsb/nceas/metacat/dataone/CrudService.java
97 97

  
98 98
    private MetacatHandler handler;
99 99
    private Hashtable<String, String[]> params;
100
    Logger logMetacat = null;
100
    private Logger logMetacat = null;
101
    private Logger logCrud = null;
101 102
    
102 103
    private String metacatUrl;
103 104

  
......
122 123
    public CrudService() {
123 124
    //change crud service into a singleton.  dont pass servlet data structures here
124 125
        logMetacat = Logger.getLogger(CrudService.class);
126
        logCrud = Logger.getLogger("DataOneLogger");
125 127
        try
126 128
        {
127 129
            String server = PropertyService.getProperty("server.name");
......
188 190
            AuthToken token = new AuthToken(sessionid);
189 191
            EventLog.getInstance().log(metacatUrl,
190 192
                    username, null, "authenticate");
193
            logCrud.info("authenticate");
191 194
            return token;
192 195
        }
193 196
        catch(Exception e)
......
244 247
                logMetacat.error("Could not generate missing system metadata: " + e.getMessage());
245 248
            }
246 249
        }
250
        logCrud.info("generateMissingSystemMetadata");
247 251
    }
248 252
    
249 253
    /**
......
314 318
        logMetacat.debug("Returning from CrudService.create()");
315 319
        EventLog.getInstance().log(metacatUrl,
316 320
                username, localId, "create");
321
        logCrud.info("create localId:" + localId + " guid:" + guid);
317 322
        return guid;
318 323
    }
319 324
    
......
360 365
            String username = sessionData.getUserName();
361 366
            EventLog.getInstance().log(metacatUrl,
362 367
                    username, im.getLocalId(guid.getValue()), "update");
368
            logCrud.info("update localId:" + im.getLocalId(guid.getValue()) + " guid:" + guid);
363 369
            return guid;
364 370
        }
365 371
        catch(Exception e)
......
401 407
            String username = sessionData.getUserName();
402 408
            EventLog.getInstance().log(metacatUrl,
403 409
                    username, im.getLocalId(id.getValue()), "setAccess");
410
            logCrud.info("setAccess");
404 411
        }
405 412
        catch(Exception e)
406 413
        {
......
530 537
      String username = sessionData.getUserName();
531 538
      EventLog.getInstance().log(metacatUrl,
532 539
              username, null, "read");
540
      logCrud.info("listObjects");
533 541
      return ol;
534 542
    }
535 543
    
......
560 568
    public Identifier delete(AuthToken token, Identifier guid)
561 569
            throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
562 570
            NotImplemented {
571
        logCrud.info("delete");
563 572
        throw new NotImplemented("1000", "This method not yet implemented.");
564 573
    }
565 574

  
......
569 578
    public DescribeResponse describe(AuthToken token, Identifier guid)
570 579
            throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
571 580
            NotImplemented {
581
        logCrud.info("describe");
572 582
        throw new NotImplemented("1000", "This method not yet implemented.");
573 583
    }
574 584
    
......
629 639
            String username = sessionData.getUserName();
630 640
            EventLog.getInstance().log(metacatUrl,
631 641
                    username, im.getLocalId(guid.getValue()), "read");
642
            logCrud.info("get localId:" + localId + " guid:" + guid);
632 643
            return objectStream;
633 644

  
634 645
        } catch (McdbDocNotFoundException e) {
......
642 653
    public Checksum getChecksum(AuthToken token, Identifier guid)
643 654
            throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
644 655
            InvalidRequest, NotImplemented {
656
        logCrud.info("getChecksum");
645 657
        throw new NotImplemented("1000", "This method not yet implemented.");
646 658
    }
647 659

  
......
651 663
    public Checksum getChecksum(AuthToken token, Identifier guid, 
652 664
            String checksumAlgorithm) throws InvalidToken, ServiceFailure, 
653 665
            NotAuthorized, NotFound, InvalidRequest, NotImplemented {
666
        logCrud.info("getChecksum");
654 667
        throw new NotImplemented("1000", "This method not yet implemented.");
655 668
    }
656 669

  
......
749 762
        }
750 763
        
751 764
        log.setLogEntryList(logs);
765
        logCrud.info("getLogRecords");
752 766
        return log;
753 767
    }
754 768
    
......
828 842
            String username = sessionData.getUserName();
829 843
            EventLog.getInstance().log(metacatUrl,
830 844
                    username, im.getLocalId(guid.getValue()), "read");
845
            logCrud.info("getSystemMetadata localId: " + localId + " guid:" + guid);
831 846
            return sysmeta;
832 847
            
833 848
        } catch (McdbDocNotFoundException e) {
......
1207 1222
                            null, params, sessionData.getUserName(), sessionData.getGroupNames());
1208 1223
        //String outputS = new String(output.toByteArray());
1209 1224
        logMetacat.debug("CrudService.insertDocument - Metacat returned: " + result);
1210
//        if (!(outputS.indexOf("<success>") > 0 && outputS.indexOf(localId) > 0)) {
1211
//            throw new ServiceFailure(1190, outputS);
1212
//        }
1213 1225
        logMetacat.debug("Finsished inserting xml document with id " + localId);
1214 1226
        return localId;
1215 1227
    }
src/edu/ucsb/nceas/metacat/replication/ReplicationHandler.java
74 74
//  private static final AbstractDatabase dbAdapter = MetacatUtil.dbAdapter;
75 75
  private static Logger logReplication = Logger.getLogger("ReplicationLogging");
76 76
  private static Logger logMetacat = Logger.getLogger(ReplicationHandler.class);
77
  private static Logger logD1 = Logger.getLogger("DataOneLogger");
78
  
77 79
  private static int DOCINSERTNUMBER = 1;
78 80
  private static int DOCERRORNUMBER  = 1;
79 81
  private static int REVINSERTNUMBER = 1;
......
471 473
       //return DBConnection
472 474
       DBConnectionPool.returnDBConnection(dbConn, serialNumber);
473 475
    }//finally
476
    logD1.info("replication.create localId:" + accNumber);
474 477
  }
475 478

  
476 479

  
......
610 613
       //return DBConnection
611 614
       DBConnectionPool.returnDBConnection(dbConn, serialNumber);
612 615
    }//finally
616
    logD1.info("replication.create localId:" + accNumber);
613 617
  }
614 618

  
615 619

  
......
656 660
       //return DBConnection
657 661
       DBConnectionPool.returnDBConnection(dbConn, serialNumber);
658 662
    }//finally
663
    logD1.info("replication.handleDeleteSingleDocument localId:" + docId);
659 664
  }
660 665

  
661 666
  /* Handle updateLastCheckTimForSingleServer*/

Also available in: Unified diff