I'm **looking for a way to automate** an arduous mechanical procedure that I perform too often: implementing **trace logging on a method**.

Consider the following fictitious methods.

```
private void createBaz(String key, String databaseConfigKey, String query) {
    this.queries.put(key, query);
    this.databases.put(key, Database.forKey(databaseConfigKey));
}

private void createFrob(String key, String hostname) {
    this.frobs.put(key, query);
}

```

Now, I'll add some useful logging.

```
private void createBaz(String key, String databaseConfigKey, String query) {
    this.log.trace("createBaz(" + key + ", " + databaseConfigKey + ", " + query + ")");
    this.queries.put(key, query);
    this.databases.put(key, Database.forKey(databaseConfigKey));
}

private void createFrob(String key, String hostname) {
    this.log.trace("createFrob(" + key + ", " + hostname + ")");
    this.frobs.put(key, query);
}

```

Note the similarities of the two log.trace calls.

I've typed out a lot of log lines like that, and I'm tired of it. I'm looking for something like this:

```
private void createBaz(String key, String databaseConfigKey, String query) {
    doLogTrace();
    this.queries.put(key, query);
    this.databases.put(key, Database.forKey(databaseConfigKey));
}

private void createFrob(String key, String hostname) {
    doLogTrace();
    this.frobs.put(key, query);
}

```

**I might need help refining my question!**

It doesn't matter to me if `doLogTrace();` happens to be a longer string like `doLogTrace(this,System.foo(),#$^#$&^$#);`. It could even be multiple lines, so long as it's the SAME string wherever I use it. Then I could just put that string in a keyboard macro.

**Things I've considered**

* ~~AspectJ~~ Not for this project.
* IDE magic. I could probably write a macro for emacs that could jump to the top of the method, copy the name and parameter list, drop one line down, paste it and automagically edit it into `log.trace("<methodName>(" + <method1> + ["," + <methodN>] +")");`... But, normally my .java files are only open in Eclipse... :/