# MethodLogger

This aspect enables you to log method calls and their results. You will have to bind it to the methods you want it to listen to. It has one constructor argument:

| Name       | Type    | Required | Default | Description                                        |
| ---------- | ------- | -------- | ------- | -------------------------------------------------- |
| logResults | boolean | false    | true    | Whether to log the results of method calls or not. |

```javascript
// Map the Aspect
mapAspect("MethodLogger")
    .to("coldbox.system.aop.aspects.MethodLogger")
    .initArg(name="logResults",value="true or false");

// Bind the Aspect to all service class methods
bindAspect(classes=matcher().regex('.*Service'), methods=matcher().any(), aspects="MethodLogger");
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wirebox.ortusbooks.com/5/aspect-oriented-programming/aop-intro/included-aspects/methodlogger.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
